// Games.Tala.js
//


Type.createNamespace('Games.Tala');

////////////////////////////////////////////////////////////////////////////////
// Games.Tala.ActionState

Games.Tala.ActionState = function() { 
    /// <field name="start" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="yourTurn" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="pick" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="eat" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="someOneTurn" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="lastTurn" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="u" type="Number" integer="true" static="true">
    /// </field>
};
Games.Tala.ActionState.prototype = {
    start: 0, 
    yourTurn: 1, 
    pick: 2, 
    eat: 3, 
    someOneTurn: 4, 
    lastTurn: 5, 
    u: 6
}
Games.Tala.ActionState.createEnum('Games.Tala.ActionState', false);


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.DevilFishTransactionReason

Games.Tala.DevilFishTransactionReason = function() { 
    /// <field name="ufKhan" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="anChot" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="gameEnd" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="uDen" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="moms" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="uf" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="denLang" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="rollback" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="anNormal" type="Number" integer="true" static="true">
    /// </field>
};
Games.Tala.DevilFishTransactionReason.prototype = {
    ufKhan: 0, 
    anChot: 1, 
    gameEnd: 2, 
    uDen: 3, 
    moms: 4, 
    uf: 5, 
    denLang: 6, 
    rollback: 7, 
    anNormal: 8
}
Games.Tala.DevilFishTransactionReason.createEnum('Games.Tala.DevilFishTransactionReason', false);


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.ActionPart

Games.Tala.ActionPart = function Games_Tala_ActionPart() {
    /// <field name="_view$1" type="Games.Tala.ActionView">
    /// </field>
    /// <field name="_bus$1" type="ZeroScript.Core.IBus">
    /// </field>
    /// <field name="_attackCard$1" type="Number" integer="true">
    /// </field>
    Games.Tala.ActionPart.constructBase(this);
}
Games.Tala.ActionPart.prototype = {
    _view$1: null,
    _bus$1: null,
    _attackCard$1: 0,
    
    initPart: function Games_Tala_ActionPart$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        this._bus$1 = container.get_bus();
        this._view$1 = new Games.Tala.ActionView();
        this._view$1.add_attack(Delegate.create(this, this._onAttack$1));
        this._view$1.add_sort(Delegate.create(this, this._onSort$1));
        this._view$1.add_u(Delegate.create(this, this._onU$1));
        this._view$1.add_show(Delegate.create(this, this._onShow$1));
        this._bus$1.subcribe('YourCards', Delegate.create(this, this._onGameStart$1));
        this._bus$1.subcribe('GameEnd', Delegate.create(this, this._onGameEnd$1));
        this._bus$1.subcribe('ClientDevilFishMove', Delegate.create(this, this._onClientMove$1));
        this._bus$1.subcribe('DevilFishMoveResponse', Delegate.create(this, this._onMoveResponse$1));
        this._bus$1.subcribe('ChangeTurn', Delegate.create(this, this._onChangeTurn$1));
        this._bus$1.subcribe('YourTurn', Delegate.create(this, this._onYourTurn$1));
        this._bus$1.subcribe('DevilFishPickResponse', Delegate.create(this, this._onPickResponse$1));
        this._bus$1.subcribe('DevilFishEatResponse', Delegate.create(this, this._onEatResponse$1));
        this._bus$1.subcribe('on.last.turn', Delegate.create(this, this._onLastTurn$1));
    },
    
    _onYourTurn$1: function Games_Tala_ActionPart$_onYourTurn$1(item) {
        /// <param name="item" type="Games.Base.Messages.YourTurn">
        /// </param>
        this._view$1.set_state(Games.Tala.ActionState.yourTurn);
    },
    
    _onEatResponse$1: function Games_Tala_ActionPart$_onEatResponse$1(item) {
        /// <param name="item" type="Games.Tala.DevilFishEatResponse">
        /// </param>
        this._view$1.set_state(Games.Tala.ActionState.eat);
    },
    
    _onPickResponse$1: function Games_Tala_ActionPart$_onPickResponse$1(item) {
        /// <param name="item" type="Games.Tala.DevilFishPickResponse">
        /// </param>
        this._view$1.set_state(Games.Tala.ActionState.pick);
    },
    
    _onChangeTurn$1: function Games_Tala_ActionPart$_onChangeTurn$1(m) {
        /// <param name="m" type="Games.Base.Messages.ChangeTurn">
        /// </param>
        if (m.userId !== Global.get_user().id) {
            this._view$1.set_state(Games.Tala.ActionState.someOneTurn);
        }
    },
    
    _onGameStart$1: function Games_Tala_ActionPart$_onGameStart$1(item) {
        /// <param name="item" type="Object">
        /// </param>
        this._view$1.set_state(Games.Tala.ActionState.start);
    },
    
    _onLastTurn$1: function Games_Tala_ActionPart$_onLastTurn$1(d) {
        /// <param name="d" type="Object">
        /// </param>
        this._view$1.set_state(Games.Tala.ActionState.lastTurn);
    },
    
    _onClientMove$1: function Games_Tala_ActionPart$_onClientMove$1(m) {
        /// <param name="m" type="Games.Tala.ClientDevilFishMove">
        /// </param>
        this._publishAttackAction$1(m.senderId, m.card);
    },
    
    _onMoveResponse$1: function Games_Tala_ActionPart$_onMoveResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishMoveResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            Games.Base.MessageBox.notify('Kh\u00f4ng \u0111\u00e1nh \u0111\u01b0\u1ee3c!');
        }
        else {
            var userId = Global.get_user().id;
            Games.Tala.VmgPhoneCardInHand.instance.attacking = false;
            this._publishAttackAction$1(userId, m.card);
        }
    },
    
    _publishAttackAction$1: function Games_Tala_ActionPart$_publishAttackAction$1(userId, card) {
        /// <param name="userId" type="Number" integer="true">
        /// </param>
        /// <param name="card" type="Number" integer="true">
        /// </param>
        this._bus$1.publish('player.attack', new Games.Tala.PlayerAttack(userId, card));
    },
    
    _onAttack$1: function Games_Tala_ActionPart$_onAttack$1() {
        if (!Games.Tala.TalaState.current.get_isYourTurn()) {
            return;
        }
        var cards = Games.Tala.VmgPhoneCardInHand.instance.getSelectedCards();
        if (cards.get_count() <= 0) {
            return;
        }
        this._attackCard$1 = cards.get_item(0);
        if (Games.Tala.TalaState.current.isLastTurn) {
            this._bus$1.publish('player.last.attack', new Games.Tala.PlayerAttack(Global.get_user().id, this._attackCard$1));
        }
        else {
            Games.Tala.VmgPhoneCardInHand.instance.attacking = true;
            Games.Base.GameRequest.send('Move.htm', 'cards', [ this._attackCard$1 ]);
        }
        this._attackCard$1 = -1;
    },
    
    _onShow$1: function Games_Tala_ActionPart$_onShow$1() {
        if (!Games.Tala.TalaState.current.get_isYourTurn()) {
            return;
        }
        var cards = Games.Tala.VmgPhoneCardInHand.instance.getSelectedCards();
        if (cards.get_count() > 0) {
            var arr = cards.toArray();
            Games.Base.GameRequest.send('ShowPhom.htm', 'cards', arr);
        }
        else {
            this._bus$1.publish('player.show.phom', null);
        }
    },
    
    _onU$1: function Games_Tala_ActionPart$_onU$1() {
        if (!Games.Tala.TalaState.current.get_isYourTurn()) {
            return;
        }
        Games.Base.GameRequest.send('U.htm');
    },
    
    _onSort$1: function Games_Tala_ActionPart$_onSort$1() {
        Games.Tala.VmgPhoneCardInHand.instance.sort();
    },
    
    _onGameEnd$1: function Games_Tala_ActionPart$_onGameEnd$1(m) {
        /// <param name="m" type="Games.Base.Messages.GameEnd">
        /// </param>
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.ActionView

Games.Tala.ActionView = function Games_Tala_ActionView() {
    /// <field name="_attack" type="Object" domElement="true">
    /// </field>
    /// <field name="_sort" type="Object" domElement="true">
    /// </field>
    /// <field name="_u" type="Object" domElement="true">
    /// </field>
    /// <field name="_show" type="Object" domElement="true">
    /// </field>
    /// <field name="_state" type="Games.Tala.ActionState">
    /// </field>
    /// <field name="__attack" type="Callback">
    /// </field>
    /// <field name="__sort" type="Callback">
    /// </field>
    /// <field name="__show" type="Callback">
    /// </field>
    /// <field name="__u" type="Callback">
    /// </field>
    this._state = Games.Tala.ActionState.start;
    this._initDoms();
    this._initEvents();
}
Games.Tala.ActionView.prototype = {
    _attack: null,
    _sort: null,
    _u: null,
    _show: null,
    
    add_attack: function Games_Tala_ActionView$add_attack(value) {
        /// <param name="value" type="Function" />
        this.__attack = Delegate.combine(this.__attack, value);
    },
    remove_attack: function Games_Tala_ActionView$remove_attack(value) {
        /// <param name="value" type="Function" />
        this.__attack = Delegate.remove(this.__attack, value);
    },
    
    __attack: null,
    
    add_sort: function Games_Tala_ActionView$add_sort(value) {
        /// <param name="value" type="Function" />
        this.__sort = Delegate.combine(this.__sort, value);
    },
    remove_sort: function Games_Tala_ActionView$remove_sort(value) {
        /// <param name="value" type="Function" />
        this.__sort = Delegate.remove(this.__sort, value);
    },
    
    __sort: null,
    
    add_show: function Games_Tala_ActionView$add_show(value) {
        /// <param name="value" type="Function" />
        this.__show = Delegate.combine(this.__show, value);
    },
    remove_show: function Games_Tala_ActionView$remove_show(value) {
        /// <param name="value" type="Function" />
        this.__show = Delegate.remove(this.__show, value);
    },
    
    __show: null,
    
    add_u: function Games_Tala_ActionView$add_u(value) {
        /// <param name="value" type="Function" />
        this.__u = Delegate.combine(this.__u, value);
    },
    remove_u: function Games_Tala_ActionView$remove_u(value) {
        /// <param name="value" type="Function" />
        this.__u = Delegate.remove(this.__u, value);
    },
    
    __u: null,
    
    get_state: function Games_Tala_ActionView$get_state() {
        /// <value type="Games.Tala.ActionState"></value>
        return this._state;
    },
    set_state: function Games_Tala_ActionView$set_state(value) {
        /// <value type="Games.Tala.ActionState"></value>
        this._state = value;
        if (Games.Tala.TalaState.current.get_isViewer()) {
            this._hideAllActions();
            return;
        }
        switch (this._state) {
            case Games.Tala.ActionState.start:
                this._enable(this._attack, false);
                this._enable(this._show, false);
                this._enable(this._u, true);
                this._enable(this._sort, true);
                break;
            case Games.Tala.ActionState.eat:
            case Games.Tala.ActionState.pick:
                this._enable(this._attack, true);
                break;
            case Games.Tala.ActionState.lastTurn:
                this._enable(this._show, true);
                break;
            case Games.Tala.ActionState.u:
                this._enable(this._u, true);
                break;
            case Games.Tala.ActionState.yourTurn:
                var cards = Games.Tala.VmgPhoneCardInHand.instance.get_cards();
                this._enable(this._attack, cards.get_count() === 10);
                break;
            case Games.Tala.ActionState.someOneTurn:
                this._enable(this._attack, false);
                this._enable(this._show, false);
                break;
        }
        return value;
    },
    
    _hideAllActions: function Games_Tala_ActionView$_hideAllActions() {
        ZeroScript.Core.DomHelper.visible(this._attack, false);
        ZeroScript.Core.DomHelper.visible(this._sort, false);
        ZeroScript.Core.DomHelper.visible(this._show, false);
        ZeroScript.Core.DomHelper.visible(this._u, false);
    },
    
    _initEvents: function Games_Tala_ActionView$_initEvents() {
        EventHelper.attachEvent(this._attack, EventHelper.click, Delegate.create(this, this._onAttack));
        EventHelper.attachEvent(this._sort, EventHelper.click, Delegate.create(this, this._onSort));
        EventHelper.attachEvent(this._show, EventHelper.click, Delegate.create(this, this._onShow));
        EventHelper.attachEvent(this._u, EventHelper.click, Delegate.create(this, this._onU));
        ZeroScript.Core.JQuery.JQueryHelper.select('.button_moichoi').click(Delegate.create(this, function() {
            Games.Base.GameRequest.send('inviteplay.htm');
        }));
    },
    
    _isEnable: function Games_Tala_ActionView$_isEnable(dom) {
        /// <param name="dom" type="Object" domElement="true">
        /// </param>
        /// <returns type="Boolean"></returns>
        var css = dom.className;
        return css.indexOf('enabled') >= 0;
    },
    
    _enable: function Games_Tala_ActionView$_enable(dom, enable) {
        /// <param name="dom" type="Object" domElement="true">
        /// </param>
        /// <param name="enable" type="Boolean">
        /// </param>
        if (isNullOrUndefined(dom)) {
            return;
        }
        ZeroScript.Core.DomHelper.visible(dom, true);
        var css = dom.className;
        if (!enable) {
            css = css.replace('enabled', 'disabled');
        }
        else {
            css = css.replace('disabled', 'enabled');
        }
        dom.className = css;
    },
    
    _onShow: function Games_Tala_ActionView$_onShow(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        if (!this._isEnable(this._show)) {
            return;
        }
        if (this.__show != null) {
            this.__show.invoke();
        }
    },
    
    _onU: function Games_Tala_ActionView$_onU(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        if (this.__u != null) {
            this.__u.invoke();
        }
    },
    
    _onSort: function Games_Tala_ActionView$_onSort(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        if (this.__sort != null) {
            this.__sort.invoke();
        }
    },
    
    _onAttack: function Games_Tala_ActionView$_onAttack(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        if (!this._isEnable(this._attack)) {
            return;
        }
        if (this.__attack != null) {
            this.__attack.invoke();
        }
    },
    
    _initDoms: function Games_Tala_ActionView$_initDoms() {
        this._attack = document.getElementById('button_attack');
        this._sort = document.getElementById('button_sort');
        this._show = document.getElementById('button_ha_bai');
        this._u = document.getElementById('button_u');
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.ActivityPart

Games.Tala.ActivityPart = function Games_Tala_ActivityPart() {
    /// <field name="_element$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_transMsg$1" type="Array" elementType="String">
    /// </field>
    Games.Tala.ActivityPart.constructBase(this);
}
Games.Tala.ActivityPart.prototype = {
    _element$1: null,
    _transMsg$1: null,
    
    initPart: function Games_Tala_ActivityPart$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        var bus = container.get_bus();
        bus.subcribe('game.activity', Delegate.create(this, this._onGameActivity$1));
        bus.subcribe('NewTransaction', Delegate.create(this, this._onNewTransaction$1));
        this._element$1 = document.getElementById('chat_content');
        this._initMessages$1();
    },
    
    _initMessages$1: function Games_Tala_ActivityPart$_initMessages$1() {
        this._transMsg$1 = new Array(10);
        this._transMsg$1[Games.Tala.DevilFishTransactionReason.anChot] = '\u0103n ch\u1ed1t';
        this._transMsg$1[Games.Tala.DevilFishTransactionReason.denLang] = '\u0111\u1ec1n l\u00e0ng';
        this._transMsg$1[Games.Tala.DevilFishTransactionReason.moms] = 'm\u00f3m!';
    },
    
    _onNewTransaction$1: function Games_Tala_ActivityPart$_onNewTransaction$1(m) {
        /// <param name="m" type="Games.Tala.NewTransaction">
        /// </param>
        var rawUsers = Games.Tala.TalaState.current.get_session().rawUsers;
        if (rawUsers[m.fromSlot] == null || rawUsers[m.toSlot] == null) {
            return;
        }
        var text = this._activityToText$1(rawUsers[m.fromSlot].firstName, rawUsers[m.toSlot].firstName, m.reason, m.amount);
        this._display$1(text, true);
    },
    
    _activityToText$1: function Games_Tala_ActivityPart$_activityToText$1(from, to, reason, amount) {
        /// <param name="from" type="String">
        /// </param>
        /// <param name="to" type="String">
        /// </param>
        /// <param name="reason" type="Number" integer="true">
        /// </param>
        /// <param name="amount" type="Number" integer="true">
        /// </param>
        /// <returns type="String"></returns>
        var message = this._transMsg$1[reason];
        if (isNullOrUndefined(message) || message === '') {
            return String.Empty;
        }
        if (reason === Games.Tala.DevilFishTransactionReason.gameEnd) {
            return String.Empty;
        }
        if (reason === Games.Tala.DevilFishTransactionReason.anChot) {
            return String.format('{0} {1} {2}, {3}<br>', to, message, from, Format.currency(amount));
        }
        return String.format('{0} {1}<br>', from, message);
    },
    
    _onGameActivity$1: function Games_Tala_ActivityPart$_onGameActivity$1(text) {
        /// <param name="text" type="String">
        /// </param>
        var dom = this._display$1(text, false);
        window.toggleGameResult(dom);;
    },
    
    _display$1: function Games_Tala_ActivityPart$_display$1(text, isFeed) {
        /// <param name="text" type="String">
        /// </param>
        /// <param name="isFeed" type="Boolean">
        /// </param>
        /// <returns type="Object" domElement="true"></returns>
        var d = document.createElement('p');
        if (text === String.Empty) {
            return d;
        }
        if (isFeed) {
            d.className = 'txt_special';
        }
        ZeroScript.Core.JQuery.JQueryHelper.select(d).html(text);
        this._element$1.appendChild(d);
        this._element$1.scrollTop = this._element$1.scrollHeight;
        return d;
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.BubblePart

Games.Tala.BubblePart = function Games_Tala_BubblePart() {
    /// <field name="_maxPlayers$1" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="_bubbles$1" type="Array" elementType="BubbleView">
    /// </field>
    this._bubbles$1 = new Array(Games.Tala.BubblePart._maxPlayers$1);
    Games.Tala.BubblePart.constructBase(this);
    for (var i = 0; i < Games.Tala.BubblePart._maxPlayers$1; i++) {
        var dom = document.getElementById('bubble_' + i);
        if (dom == null) {
            break;
        }
        this._bubbles$1[i] = new Games.Tala.BubbleView(dom);
    }
}
Games.Tala.BubblePart.prototype = {
    
    initPart: function Games_Tala_BubblePart$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        var b = container.get_bus();
        b.subcribe('ClientChatMessage', Delegate.create(this, this._onChatReceive$1));
    },
    
    _onChatReceive$1: function Games_Tala_BubblePart$_onChatReceive$1(m) {
        /// <param name="m" type="Games.Base.Messages.ChatMessage">
        /// </param>
        var seat = Games.Tala.TalaState.current.getSeat(m.senderId);
        if (seat < 0 || Games.Base.Data.User.isBlock(m.senderId)) {
            return;
        }
        this._bubbles$1[seat].set_text(m.text);
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.BubbleView

Games.Tala.BubbleView = function Games_Tala_BubbleView(dom) {
    /// <param name="dom" type="Object" domElement="true">
    /// </param>
    /// <field name="_commboTime" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="_autoHideTimeoutId" type="Number" integer="true">
    /// </field>
    /// <field name="_lastMsg" type="String">
    /// </field>
    /// <field name="_lastTime" type="Date">
    /// </field>
    /// <field name="_jElement" type="ZeroScript.Core.JQuery.IJQuery">
    /// </field>
    this._jElement = ZeroScript.Core.JQuery.JQueryHelper.select(dom);
}
Games.Tala.BubbleView.prototype = {
    _autoHideTimeoutId: 0,
    _lastMsg: null,
    _lastTime: null,
    _jElement: null,
    
    get_text: function Games_Tala_BubbleView$get_text() {
        /// <value type="String"></value>
        return this._jElement.html();
    },
    set_text: function Games_Tala_BubbleView$set_text(value) {
        /// <value type="String"></value>
        this._clearAutoHide();
        this._appendText(value);
        this._show();
        this._autoHide();
        return value;
    },
    
    setEmoticon: function Games_Tala_BubbleView$setEmoticon(mood) {
        /// <param name="mood" type="Number" integer="true">
        /// </param>
        var html = this._getRandomEmo(mood);
        this.set_text(html);
    },
    
    _getRandomEmo: function Games_Tala_BubbleView$_getRandomEmo(mood) {
        /// <param name="mood" type="Number" integer="true">
        /// </param>
        /// <returns type="String"></returns>
        var i = Math.round(Math.random() * 4) + 1;
        var t = (mood === Games.Base.Data.EmoticonData.happy) ? 'happy' : 'sad';
        return String.format('<i class=\'img_emo emo_{0}_{1}\'></i>', t, i);
    },
    
    _appendText: function Games_Tala_BubbleView$_appendText(value) {
        /// <param name="value" type="String">
        /// </param>
        var msg = Format.toChat(value);
        if (!String.isNullOrEmpty(this._lastMsg) && Date.get_now().getTime() - this._lastTime.getTime() < Games.Tala.BubbleView._commboTime) {
            msg = this._lastMsg + '<br/>' + msg;
        }
        this._jElement.html(msg);
        this._lastMsg = value;
        this._lastTime = Date.get_now();
    },
    
    _clearAutoHide: function Games_Tala_BubbleView$_clearAutoHide() {
        window.clearTimeout(this._autoHideTimeoutId);
    },
    
    _autoHide: function Games_Tala_BubbleView$_autoHide() {
        this._autoHideTimeoutId = window.setTimeout(Delegate.create(this, this._hide), 7 * 1000);
    },
    
    _hide: function Games_Tala_BubbleView$_hide() {
        this._jElement.hide();
        this._lastMsg = String.Empty;
    },
    
    _show: function Games_Tala_BubbleView$_show() {
        this._jElement.show();
    },
    
    clear: function Games_Tala_BubbleView$clear() {
        this._clearAutoHide();
        this._hide();
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.GuiPhom

Games.Tala.GuiPhom = function Games_Tala_GuiPhom(card, phomId, phomOwnerId) {
    /// <param name="card" type="Number" integer="true">
    /// </param>
    /// <param name="phomId" type="Number" integer="true">
    /// </param>
    /// <param name="phomOwnerId" type="Number" integer="true">
    /// </param>
    /// <field name="_card" type="Number" integer="true">
    /// </field>
    /// <field name="_phomId" type="Number" integer="true">
    /// </field>
    /// <field name="_phomOwnerId" type="Number" integer="true">
    /// </field>
    this._card = card;
    this._phomId = phomId;
    this._phomOwnerId = phomOwnerId;
}
Games.Tala.GuiPhom.prototype = {
    _card: 0,
    _phomId: 0,
    _phomOwnerId: 0,
    
    get_card: function Games_Tala_GuiPhom$get_card() {
        /// <value type="Number" integer="true"></value>
        return this._card;
    },
    
    get_phomId: function Games_Tala_GuiPhom$get_phomId() {
        /// <value type="Number" integer="true"></value>
        return this._phomId;
    },
    
    get_phomOwnerId: function Games_Tala_GuiPhom$get_phomOwnerId() {
        /// <value type="Number" integer="true"></value>
        return this._phomOwnerId;
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.Phom

Games.Tala.Phom = function Games_Tala_Phom(cards, id, ownerId) {
    /// <param name="cards" type="ZeroScript.Core.List">
    /// </param>
    /// <param name="id" type="Number" integer="true">
    /// </param>
    /// <param name="ownerId" type="Number" integer="true">
    /// </param>
    /// <field name="_cards" type="ZeroScript.Core.List">
    /// </field>
    /// <field name="_id" type="Number" integer="true">
    /// </field>
    /// <field name="_ownerId" type="Number" integer="true">
    /// </field>
    this._cards = cards;
    this._id = id;
    this._ownerId = ownerId;
}
Games.Tala.Phom.prototype = {
    _cards: null,
    _id: 0,
    _ownerId: 0,
    
    get_cards: function Games_Tala_Phom$get_cards() {
        /// <value type="ZeroScript.Core.List"></value>
        return this._cards;
    },
    set_cards: function Games_Tala_Phom$set_cards(value) {
        /// <value type="ZeroScript.Core.List"></value>
        this._cards = value;
        return value;
    },
    
    get_id: function Games_Tala_Phom$get_id() {
        /// <value type="Number" integer="true"></value>
        return this._id;
    },
    set_id: function Games_Tala_Phom$set_id(value) {
        /// <value type="Number" integer="true"></value>
        this._id = value;
        return value;
    },
    
    get_ownerId: function Games_Tala_Phom$get_ownerId() {
        /// <value type="Number" integer="true"></value>
        return this._ownerId;
    },
    set_ownerId: function Games_Tala_Phom$set_ownerId(value) {
        /// <value type="Number" integer="true"></value>
        this._ownerId = value;
        return value;
    }
}


////////////////////////////////////////////////////////////////////////////////
// PhomExtractor

PhomExtractor = function PhomExtractor() {
    /// <field name="_cardSet" type="Array" elementType="Array">
    /// </field>
    /// <field name="_phomMark" type="Array" elementType="Array">
    /// </field>
    /// <field name="_curPhomMark" type="Array" elementType="Array">
    /// </field>
    /// <field name="_curPoint" type="Number" integer="true">
    /// </field>
    /// <field name="_countEatenCardInHand" type="Number" integer="true">
    /// </field>
    /// <field name="_countPhom" type="Number" integer="true">
    /// </field>
    /// <field name="_foundU" type="Boolean">
    /// </field>
    /// <field name="_countPhomNgang" type="Array" elementType="Array">
    /// </field>
    /// <field name="_countPhomDoc" type="Array" elementType="Array">
    /// </field>
    /// <field name="_phoms" type="ZeroScript.Core.List">
    /// </field>
    /// <field name="_cardEaten" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="_loangDoc" type="Array" elementType="Array">
    /// </field>
    /// <field name="_loangNgang" type="Array" elementType="Array">
    /// </field>
    this._phoms = new ZeroScript.Core.List();
    this._loangDoc = new Array(4);
    for (var i = 0; i < this._loangDoc.length; i++) {
        this._loangDoc[i] = new Array(2);
    }
    this._loangNgang = new Array(3);
    for (var i = 0; i < this._loangNgang.length; i++) {
        this._loangNgang[i] = new Array(2);
    }
    this._loangDoc[0][0] = [ 0, 1, 2 ];
    this._loangDoc[0][1] = [ 0, 0, 0 ];
    this._loangDoc[1][0] = [ 0, 1, 3 ];
    this._loangDoc[1][1] = [ 0, 0, 0 ];
    this._loangDoc[2][0] = [ 0, 2, 3 ];
    this._loangDoc[2][1] = [ 0, 0, 0 ];
    this._loangDoc[3][0] = [ 0, 1, 2, 3 ];
    this._loangDoc[3][1] = [ 0, 0, 0, 0 ];
    this._loangNgang[0][0] = [ 0, 0, 0 ];
    this._loangNgang[0][1] = [ 0, 1, 2 ];
    this._loangNgang[1][0] = [ 0, 0, 0, 0 ];
    this._loangNgang[1][1] = [ 0, 1, 2, 3 ];
    this._loangNgang[2][0] = [ 0, 0, 0, 0, 0 ];
    this._loangNgang[2][1] = [ 0, 1, 2, 3, 4 ];
}
PhomExtractor._init2DArray = function PhomExtractor$_init2DArray(w, h) {
    /// <param name="w" type="Number" integer="true">
    /// </param>
    /// <param name="h" type="Number" integer="true">
    /// </param>
    /// <returns type="Array" elementType="Array"></returns>
    var a = new Array(w);
    for (var i = 0; i < a.length; i++) {
        a[i] = new Array(h);
        for (var j = 0; j < h; j++) {
            a[i][j] = 0;
        }
    }
    return a;
}
PhomExtractor._clone2DArray = function PhomExtractor$_clone2DArray(array) {
    /// <param name="array" type="Array" elementType="Array">
    /// </param>
    /// <returns type="Array" elementType="Array"></returns>
    var a = new Array(array.length);
    for (var i = 0; i < array.length; i++) {
        var ai = array[i];
        if (ai == null) {
            continue;
        }
        a[i] = new Array(ai.length);
        for (var j = 0; j < ai.length; j++) {
            a[i][j] = ai[j];
        }
    }
    return a;
}
PhomExtractor._getArrayDimention = function PhomExtractor$_getArrayDimention(array, dimention) {
    /// <param name="array" type="Array" elementType="Array">
    /// </param>
    /// <param name="dimention" type="Number" integer="true">
    /// </param>
    /// <returns type="Number" integer="true"></returns>
    if (dimention === 0) {
        return array.length;
    }
    if (dimention === 1 && array[0] != null) {
        return array[0].length;
    }
    return -1;
}
PhomExtractor._mergeResult = function PhomExtractor$_mergeResult(guis, guiDuoc, index) {
    /// <param name="guis" type="ZeroScript.Core.List">
    /// </param>
    /// <param name="guiDuoc" type="ZeroScript.Core.List">
    /// </param>
    /// <param name="index" type="Number" integer="true">
    /// </param>
    /// <returns type="ZeroScript.Core.List"></returns>
    var l = new ZeroScript.Core.List();
    for (var i = 0; i < index; i++) {
        l.add(guiDuoc.get_item(i));
    }
    l.add(guis.get_item(index));
    for (var i = index; i < guiDuoc.get_count(); i++) {
        l.add(guiDuoc.get_item(i));
    }
    return l;
}
PhomExtractor._coTheGui = function PhomExtractor$_coTheGui(card, phom) {
    /// <param name="card" type="Number" integer="true">
    /// </param>
    /// <param name="phom" type="ZeroScript.Core.List">
    /// </param>
    /// <returns type="Boolean"></returns>
    var cards = phom.clone();
    cards.add(card);
    return PhomExtractor._isPhom(cards);
}
PhomExtractor._isPhom = function PhomExtractor$_isPhom(cards) {
    /// <param name="cards" type="ZeroScript.Core.List">
    /// </param>
    /// <returns type="Boolean"></returns>
    cards.sort(Delegate.create(null, function(a, b) {
        var s1 = a;
        var s2 = b;
        if (s1 > s2) {
            return 1;
        }
        if (s1 < s2) {
            return -1;
        }
        return 0;
    }));
    return (PhomExtractor._isPhomNgang(cards) || PhomExtractor._isPhomDoc(cards));
}
PhomExtractor._isPhomDoc = function PhomExtractor$_isPhomDoc(cards) {
    /// <param name="cards" type="ZeroScript.Core.List">
    /// </param>
    /// <returns type="Boolean"></returns>
    for (var i = 1; i < cards.get_count(); i++) {
        var c = cards.get_item(i);
        var preC = cards.get_item(i - 1);
        if (PhomExtractor._getCardType(c) !== PhomExtractor._getCardType(preC)) {
            return false;
        }
        if (PhomExtractor._getCardValue(c) - PhomExtractor._getCardValue(preC) !== 1) {
            return false;
        }
    }
    return true;
}
PhomExtractor._isPhomNgang = function PhomExtractor$_isPhomNgang(cards) {
    /// <param name="cards" type="ZeroScript.Core.List">
    /// </param>
    /// <returns type="Boolean"></returns>
    for (var i = 1; i < cards.get_count(); i++) {
        if (PhomExtractor._getCardValue(cards.get_item(i)) !== PhomExtractor._getCardValue(cards.get_item(i - 1))) {
            return false;
        }
    }
    return true;
}
PhomExtractor._getCardType = function PhomExtractor$_getCardType(c) {
    /// <param name="c" type="Number" integer="true">
    /// </param>
    /// <returns type="Number" integer="true"></returns>
    return Math.floor(c / 13);
}
PhomExtractor._getCardValue = function PhomExtractor$_getCardValue(c) {
    /// <param name="c" type="Number" integer="true">
    /// </param>
    /// <returns type="Number" integer="true"></returns>
    return c % 13;
}
PhomExtractor._tinhDiem = function PhomExtractor$_tinhDiem(phomsGui) {
    /// <param name="phomsGui" type="ZeroScript.Core.List">
    /// </param>
    /// <returns type="Number" integer="true"></returns>
    var d = 0;
    for (var i = 0; i < phomsGui.get_count(); i++) {
        var guiPhom = phomsGui.get_item(i);
        if (guiPhom != null) {
            d += PhomExtractor._getCardValue(guiPhom.get_card()) + 1;
        }
    }
    return d;
}
PhomExtractor.prototype = {
    _cardSet: null,
    _phomMark: null,
    _curPhomMark: null,
    _curPoint: 0,
    _countEatenCardInHand: 0,
    _countPhom: 0,
    _foundU: false,
    _countPhomNgang: null,
    _countPhomDoc: null,
    _phoms: null,
    _loangDoc: null,
    _loangNgang: null,
    
    extract: function PhomExtractor$extract(cards, eatenCards) {
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        /// <param name="eatenCards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        /// <returns type="ZeroScript.Core.List"></returns>
        var cardSet = new Array(4);
        for (var i = 0; i < 4; i++) {
            cardSet[i] = new Array(13);
            for (var j = 0; j < 13; j++) {
                cardSet[i][j] = 0;
            }
        }
        for (var i = 0; i < eatenCards.length; i++) {
            var c = eatenCards[i];
            if (!cards.contains(c)) {
                throw new Error('Card in hand not contain eatten cards : ' + c);
            }
        }
        for (var i = 0; i < cards.length; i++) {
            var type = PhomExtractor._getCardType(cards[i]);
            var value = PhomExtractor._getCardValue(cards[i]);
            if (eatenCards.contains(cards[i])) {
                cardSet[type][value] = PhomExtractor._cardEaten;
            }
            else {
                cardSet[type][value] = 1;
            }
        }
        return this._checkU(cardSet);
    },
    
    _checkU: function PhomExtractor$_checkU(cardSet) {
        /// <param name="cardSet" type="Array" elementType="Array">
        /// </param>
        /// <returns type="ZeroScript.Core.List"></returns>
        this._cardSet = cardSet;
        this._init();
        this._innerCheck(0, 0);
        this._phomMark = this._curPhomMark;
        this._printPhom();
        return this._phoms;
    },
    
    _init: function PhomExtractor$_init() {
        this._phomMark = PhomExtractor._init2DArray(4, 13);
        this._countPhomNgang = PhomExtractor._init2DArray(4, 13);
        this._countPhomDoc = PhomExtractor._init2DArray(4, 13);
        this._curPhomMark = PhomExtractor._init2DArray(4, 13);
        this._curPoint = 13 * 10;
        this._countPhom = 0;
        this._countEatenCardInHand = 0;
        this._foundU = false;
        this._phoms = new ZeroScript.Core.List();
        for (var i = 3; i >= 0; i--) {
            for (var j = 12; j >= 0; j--) {
                var countNgang = 0;
                var countDoc = 0;
                var rightColumn = j + 1;
                var belowRow = i + 1;
                if (rightColumn < 13) {
                    countNgang = this._countPhomNgang[i][rightColumn];
                }
                if (belowRow < 4) {
                    countDoc = this._countPhomDoc[belowRow][j];
                }
                if (this._cardSet[i][j] !== 0) {
                    this._countPhomNgang[i][j] = countNgang + 1;
                    this._countPhomDoc[i][j] = countDoc + 1;
                }
                else {
                    this._countPhomNgang[i][j] = 0;
                    this._countPhomDoc[i][j] = countDoc;
                }
                this._countEatenCardInHand += (this._cardSet[i][j] === PhomExtractor._cardEaten) ? 1 : 0;
            }
        }
    },
    
    _innerCheck: function PhomExtractor$_innerCheck(row, column) {
        /// <param name="row" type="Number" integer="true">
        /// </param>
        /// <param name="column" type="Number" integer="true">
        /// </param>
        if (this._foundU) {
            return;
        }
        var foundNextCard = false;
        while (row < 4) {
            while (column < 13 && (this._cardSet[row][column] === 0 || this._phomMark[row][column] !== 0)) {
                column++;
            }
            if (column < 13) {
                foundNextCard = true;
                break;
            }
            column = 0;
            row++;
        }
        if (!foundNextCard) {
            return;
        }
        if (this._countPhomDoc[row][column] >= 3) {
            for (var i = this._loangDoc.length - 1; i >= 0; i--) {
                var loang = this._loangDoc[i];
                if (this._isValidPhom(row, column, loang)) {
                    this._countPhom++;
                    this._markPhom(row, column, loang, this._countPhom);
                    this._listPhomUValid();
                    this._innerCheck(row, column + 1);
                    this._unmarkPhom(row, column, loang);
                    this._countPhom--;
                }
            }
        }
        if (this._countPhomNgang[row][column] >= 3) {
            for (var i = this._loangNgang.length - 1; i >= 0; i--) {
                var loang = this._loangNgang[i];
                var isValidPhom = this._isValidPhom(row, column, loang);
                if (isValidPhom) {
                    this._countPhom++;
                    this._markPhom(row, column, loang, this._countPhom);
                    this._listPhomUValid();
                    this._innerCheck(row, column + PhomExtractor._getArrayDimention(loang, 1));
                    this._unmarkPhom(row, column, loang);
                    this._countPhom--;
                }
            }
        }
        this._innerCheck(row, column + 1);
    },
    
    _isValidPhom: function PhomExtractor$_isValidPhom(row, column, loang) {
        /// <param name="row" type="Number" integer="true">
        /// </param>
        /// <param name="column" type="Number" integer="true">
        /// </param>
        /// <param name="loang" type="Array" elementType="Array">
        /// </param>
        /// <returns type="Boolean"></returns>
        var countEatenCard = 0;
        for (var i = 0; i < PhomExtractor._getArrayDimention(loang, 1); i++) {
            var nextRow = row + loang[0][i];
            var nextColumn = column + loang[1][i];
            if (nextRow >= 4 || nextColumn >= 13) {
                return false;
            }
            if (this._cardSet[nextRow][nextColumn] === 0 || this._phomMark[nextRow][nextColumn] !== 0) {
                return false;
            }
            if (this._cardSet[nextRow][nextColumn] === PhomExtractor._cardEaten) {
                countEatenCard++;
            }
        }
        if (countEatenCard > 1) {
            return false;
        }
        return true;
    },
    
    _markPhom: function PhomExtractor$_markPhom(row, column, loang, phomNumber) {
        /// <param name="row" type="Number" integer="true">
        /// </param>
        /// <param name="column" type="Number" integer="true">
        /// </param>
        /// <param name="loang" type="Array" elementType="Array">
        /// </param>
        /// <param name="phomNumber" type="Number" integer="true">
        /// </param>
        for (var i = 0; i < PhomExtractor._getArrayDimention(loang, 1); i++) {
            var nextRow = row + loang[0][i];
            var nextColumn = column + loang[1][i];
            this._phomMark[nextRow][nextColumn] = phomNumber;
        }
    },
    
    _unmarkPhom: function PhomExtractor$_unmarkPhom(row, column, loang) {
        /// <param name="row" type="Number" integer="true">
        /// </param>
        /// <param name="column" type="Number" integer="true">
        /// </param>
        /// <param name="loang" type="Array" elementType="Array">
        /// </param>
        this._markPhom(row, column, loang, 0);
    },
    
    _printPhom: function PhomExtractor$_printPhom() {
        var phomA = new ZeroScript.Core.List();
        var phomB = new ZeroScript.Core.List();
        var phomC = new ZeroScript.Core.List();
        for (var i = 0; i < 4; i++) {
            for (var j = 0; j < 13; j++) {
                var rawCard = i * 13 + j;
                switch (this._phomMark[i][j]) {
                    case 1:
                        phomA.add(rawCard);
                        break;
                    case 2:
                        phomB.add(rawCard);
                        break;
                    case 3:
                        phomC.add(rawCard);
                        break;
                }
            }
        }
        if (phomA.get_count() > 0) {
            this._phoms.add(phomA);
        }
        if (phomB.get_count() > 0) {
            this._phoms.add(phomB);
        }
        if (phomC.get_count() > 0) {
            this._phoms.add(phomC);
        }
        this._clearPhomMarks();
    },
    
    _clearPhomMarks: function PhomExtractor$_clearPhomMarks() {
        for (var i = 0; i < 4; i++) {
            for (var j = 0; j < 13; j++) {
                this._phomMark[i][j] = 0;
            }
        }
    },
    
    _listPhomUValid: function PhomExtractor$_listPhomUValid() {
        var point = 0;
        var countEatenCardInPhom = 0;
        for (var i = 0; i < 4; i++) {
            for (var j = 0; j < 13; j++) {
                var phom = this._phomMark[i][j];
                var card = this._cardSet[i][j];
                if (phom !== 0 && card === PhomExtractor._cardEaten) {
                    countEatenCardInPhom++;
                }
                if (card === 1 && phom === 0) {
                    point += j + 1;
                }
            }
        }
        if (countEatenCardInPhom === this._countEatenCardInHand && point < this._curPoint) {
            this._curPoint = point;
            this._curPhomMark = PhomExtractor._clone2DArray(this._phomMark);
        }
    },
    
    gui: function PhomExtractor$gui(cards, phoms) {
        /// <param name="cards" type="ZeroScript.Core.List">
        /// </param>
        /// <param name="phoms" type="ZeroScript.Core.List">
        /// </param>
        /// <returns type="ZeroScript.Core.List"></returns>
        var max = 0;
        var guis = new ZeroScript.Core.List();
        var result = new ZeroScript.Core.List();
        for (var i = 0; i < cards.get_count(); i++) {
            guis.add(null);
            result.add(null);
        }
        for (var index = 0; index < cards.get_count(); index++) {
            var card = cards.get_item(index);
            for (var i = 0; i < phoms.get_count(); i++) {
                var phom = phoms.get_item(i);
                if (PhomExtractor._coTheGui(card, phom.get_cards())) {
                    guis.set_item(index, new Games.Tala.GuiPhom(card, phom.get_id(), phom.get_ownerId()));
                    if (cards.get_count() === 1) {
                        return guis;
                    }
                    cards.removeAt(index);
                    phom.get_cards().add(card);
                    var guiDuoc = this.gui(cards, phoms);
                    var point = PhomExtractor._tinhDiem(guiDuoc);
                    point += PhomExtractor._getCardValue(card) + 1;
                    if (max < point) {
                        max = point;
                        result = PhomExtractor._mergeResult(guis, guiDuoc, index);
                    }
                    phom.get_cards().remove(card);
                    cards.set_item(index, card);
                    guis.set_item(index, null);
                }
            }
        }
        return result;
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.PhomGroup

Games.Tala.PhomGroup = function Games_Tala_PhomGroup(expandDirection) {
    /// <param name="expandDirection" type="Games.Base.Components.ExpandDirect">
    /// </param>
    /// <field name="_dur$1" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="_cards$1" type="ZeroScript.Core.List">
    /// </field>
    /// <field name="_expandDirection$1" type="Games.Base.Components.ExpandDirect">
    /// </field>
    /// <field name="ownerId" type="Number" integer="true">
    /// </field>
    /// <field name="phomId" type="Number" integer="true">
    /// </field>
    /// <field name="seatIndex" type="Number" integer="true">
    /// </field>
    /// <field name="pos" type="Number" integer="true">
    /// </field>
    /// <field name="eatenCard" type="Number" integer="true">
    /// </field>
    /// <field name="_isUsingBigCard$1" type="Boolean">
    /// </field>
    this._cards$1 = new ZeroScript.Core.List();
    this.ownerId = -1;
    this.phomId = -1;
    this.seatIndex = -1;
    this.pos = -1;
    this.eatenCard = -1;
    Games.Tala.PhomGroup.constructBase(this);
    this._expandDirection$1 = expandDirection;
    this.set_width(12 * Games.Tala.VmgPhoneConstant.spaceInPhomW + Games.Tala.VmgPhoneConstant.cardWidth);
    this.set_height(Games.Tala.VmgPhoneConstant.cardHeight);
    this._isUsingBigCard$1 = false;
}
Games.Tala.PhomGroup.prototype = {
    _expandDirection$1: 0,
    _isUsingBigCard$1: false,
    
    get_cards: function Games_Tala_PhomGroup$get_cards() {
        /// <value type="ZeroScript.Core.List"></value>
        return this._cards$1;
    },
    
    internalDraw: function Games_Tala_PhomGroup$internalDraw(canvas) {
        /// <param name="canvas" type="ZeroScript.Core.Games.ICanvas">
        /// </param>
        canvas.clear();
        if (!this._isUsingBigCard$1) {
            if (this._expandDirection$1 === Games.Base.Components.ExpandDirect.right) {
                for (var i = 0; i < this._cards$1.get_count(); i++) {
                    var card = Games.Base.Components.CardSuite.instance.get_faceUpImgs()[this._cards$1.get_item(i)];
                    canvas.draw(card, Games.Tala.VmgPhoneConstant.spaceInPhomW * i, 0, Games.Tala.VmgPhoneConstant.cardWidth, Games.Tala.VmgPhoneConstant.cardHeight, 0, 1);
                }
            }
            else {
                for (var i = this._cards$1.get_count() - 1; i >= 0; i--) {
                    var card = Games.Base.Components.CardSuite.instance.get_faceUpImgs()[this._cards$1.get_item(i)];
                    canvas.draw(card, this.get_width() - (Games.Tala.VmgPhoneConstant.cardWidth + Games.Tala.VmgPhoneConstant.spaceInPhomW * i), 0, Games.Tala.VmgPhoneConstant.cardWidth, Games.Tala.VmgPhoneConstant.cardHeight, 0, 1);
                }
            }
        }
        else {
            if (this._expandDirection$1 === Games.Base.Components.ExpandDirect.right) {
                for (var i = 0; i < this._cards$1.get_count(); i++) {
                    var card = Games.Tala.VmgPhoneCardSuite.instance.get_faceUpImgs()[this._cards$1.get_item(i)];
                    canvas.draw(card, Games.Tala.VmgPhoneConstant.spaceInPhomW * i, 0, Games.Tala.VmgPhoneConstant.bigCardWidth, Games.Tala.VmgPhoneConstant.bigCardHeight, 0, 1);
                }
            }
            else {
                for (var i = this._cards$1.get_count() - 1; i >= 0; i--) {
                    var card = Games.Tala.VmgPhoneCardSuite.instance.get_faceUpImgs()[this._cards$1.get_item(i)];
                    canvas.draw(card, this.get_width() - (Games.Tala.VmgPhoneConstant.bigCardWidth + Games.Tala.VmgPhoneConstant.spaceInPhomW * i), 0, Games.Tala.VmgPhoneConstant.bigCardWidth, Games.Tala.VmgPhoneConstant.bigCardHeight, 0, 1);
                }
            }
        }
    },
    
    attachCard: function Games_Tala_PhomGroup$attachCard(card, phomId, phomOwnerId, fromX, fromY) {
        /// <param name="card" type="Number" integer="true">
        /// </param>
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        /// <param name="phomOwnerId" type="Number" integer="true">
        /// </param>
        /// <param name="fromX" type="Number" integer="true">
        /// </param>
        /// <param name="fromY" type="Number" integer="true">
        /// </param>
        var cards = new ZeroScript.Core.List();
        cards.add(card);
        this.attachCards(cards, phomId, phomOwnerId, fromX, fromY);
    },
    
    attachCards: function Games_Tala_PhomGroup$attachCards(cards, phomId, phomOwnerId, fromX, fromY) {
        /// <param name="cards" type="ZeroScript.Core.List">
        /// </param>
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        /// <param name="phomOwnerId" type="Number" integer="true">
        /// </param>
        /// <param name="fromX" type="Number" integer="true">
        /// </param>
        /// <param name="fromY" type="Number" integer="true">
        /// </param>
        this.phomId = phomId;
        this.ownerId = phomOwnerId;
        for (var i = 0; i < cards.get_count(); i++) {
            var card = Games.Base.Components.CardSuite.instance.get(cards.get_item(i));
            card.bringToFront();
            if (this._expandDirection$1 === Games.Base.Components.ExpandDirect.right) {
                card.move(fromX, fromY, this.get_absolutePosition().x + this.get_x() + Games.Tala.VmgPhoneConstant.spaceInPhomW * i, this.get_absolutePosition().y, Games.Tala.PhomGroup._dur$1);
            }
            else {
                card.move(fromX, fromY, this.get_absolutePosition().x + this.get_width() - (Games.Tala.VmgPhoneConstant.cardWidth + Games.Tala.VmgPhoneConstant.spaceInPhomW * i), this.get_absolutePosition().y, Games.Tala.PhomGroup._dur$1);
            }
            if (!this._cards$1.contains(card.get_cardId())) {
                this._cards$1.add(card.get_cardId());
            }
        }
        window.setTimeout(Delegate.create(this, function() {
            for (var i = 0; i < cards.get_count(); i++) {
                var card = Games.Base.Components.CardSuite.instance.get(cards.get_item(i));
                card.set_visible(false);
            }
            this.redraw();
        }), Games.Tala.PhomGroup._dur$1);
    },
    
    clearCards: function Games_Tala_PhomGroup$clearCards() {
        this._cards$1.clear();
        this.phomId = -1;
        this.ownerId = -1;
        this.eatenCard = -1;
        this._isUsingBigCard$1 = false;
        this.redraw();
    },
    
    attachBigCards: function Games_Tala_PhomGroup$attachBigCards(cards, phomId, phomOwnerId, fromX, fromY) {
        /// <param name="cards" type="ZeroScript.Core.List">
        /// </param>
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        /// <param name="phomOwnerId" type="Number" integer="true">
        /// </param>
        /// <param name="fromX" type="Number" integer="true">
        /// </param>
        /// <param name="fromY" type="Number" integer="true">
        /// </param>
        this._isUsingBigCard$1 = true;
        this.phomId = phomId;
        this.ownerId = phomOwnerId;
        for (var i = 0; i < cards.get_count(); i++) {
            var card = Games.Tala.VmgPhoneCardSuite.instance.get(cards.get_item(i));
            card.bringToFront();
            if (this._expandDirection$1 === Games.Base.Components.ExpandDirect.right) {
                card.move(fromX, fromY, this.get_absolutePosition().x + this.get_x() + Games.Tala.VmgPhoneConstant.spaceInPhomW * i, this.get_absolutePosition().y, Games.Tala.PhomGroup._dur$1);
            }
            else {
                card.move(fromX, fromY, this.get_absolutePosition().x + this.get_width() - (Games.Tala.VmgPhoneConstant.cardWidth + Games.Tala.VmgPhoneConstant.spaceInPhomW * i), this.get_absolutePosition().y, Games.Tala.PhomGroup._dur$1);
            }
            if (!this._cards$1.contains(card.get_cardId())) {
                this._cards$1.add(card.get_cardId());
            }
        }
        window.setTimeout(Delegate.create(this, function() {
            for (var i = 0; i < cards.get_count(); i++) {
                var card = Games.Tala.VmgPhoneCardSuite.instance.get(cards.get_item(i));
                card.set_visible(false);
            }
            this.redraw();
        }), Games.Tala.PhomGroup._dur$1);
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.SlotPhom

Games.Tala.SlotPhom = function Games_Tala_SlotPhom(slot) {
    /// <param name="slot" type="Number" integer="true">
    /// </param>
    /// <field name="_phoms$1" type="Array" elementType="PhomGroup">
    /// </field>
    /// <field name="_slot$1" type="Number" integer="true">
    /// </field>
    /// <field name="_handX$1" type="Number" integer="true">
    /// </field>
    /// <field name="_handY$1" type="Number" integer="true">
    /// </field>
    /// <field name="__phomClick$1" type="Games.Tala.PhomClick">
    /// </field>
    this._phoms$1 = new Array(3);
    Games.Tala.SlotPhom.constructBase(this);
    this._slot$1 = slot;
    this._handX$1 = Games.Tala.VmgPhoneConstant.handXs[slot];
    this._handY$1 = Games.Tala.VmgPhoneConstant.handYs[slot];
}
Games.Tala.SlotPhom.prototype = {
    _slot$1: 0,
    _handX$1: 0,
    _handY$1: 0,
    
    loadContent: function Games_Tala_SlotPhom$loadContent() {
        Games.Tala.SlotPhom.callBase(this, 'loadContent');
        for (var i = 0; i < 3; i++) {
            this._phoms$1[i] = new Games.Tala.PhomGroup(Games.Tala.VmgPhoneConstant.phomExpands[this._slot$1]);
            var phom = this._phoms$1[i];
            phom.set_width(Games.Tala.VmgPhoneConstant.cardWidth * 3);
            phom.set_height(Games.Tala.VmgPhoneConstant.cardHeight);
            phom.seatIndex = this._slot$1;
            phom.pos = i;
            phom.set_x(Games.Tala.VmgPhoneConstant.cardDaHaX[this._slot$1][i]);
            phom.set_y(Games.Tala.VmgPhoneConstant.cardDaHaY[this._slot$1][i]);
            phom.add_click(Delegate.create(this, this._onPhomClick$1));
        }
        var order = Games.Tala.VmgPhoneConstant.phomOrders[this._slot$1];
        for (var i = 0; i < order.length; i++) {
            var tmp = order[i];
            this.add(this._phoms$1[tmp]);
        }
    },
    
    add_phomClick: function Games_Tala_SlotPhom$add_phomClick(value) {
        /// <param name="value" type="Function" />
        this.__phomClick$1 = Delegate.combine(this.__phomClick$1, value);
    },
    remove_phomClick: function Games_Tala_SlotPhom$remove_phomClick(value) {
        /// <param name="value" type="Function" />
        this.__phomClick$1 = Delegate.remove(this.__phomClick$1, value);
    },
    
    __phomClick$1: null,
    
    _onPhomClick$1: function Games_Tala_SlotPhom$_onPhomClick$1(sender, x, y) {
        /// <param name="sender" type="ZeroScript.Core.Games.IComponent">
        /// </param>
        /// <param name="x" type="Number" integer="true">
        /// </param>
        /// <param name="y" type="Number" integer="true">
        /// </param>
        var phom = sender;
        if (this.__phomClick$1 != null) {
            this.__phomClick$1.invoke(phom.phomId, phom.ownerId);
        }
    },
    
    _getNextEmptyPhom$1: function Games_Tala_SlotPhom$_getNextEmptyPhom$1() {
        /// <returns type="Games.Tala.PhomGroup"></returns>
        for (var i = 0; i < 3; i++) {
            var p = this._phoms$1[i];
            if (p.eatenCard === -1 && p.get_cards().get_count() === 0) {
                return p;
            }
        }
        return null;
    },
    
    showPhom: function Games_Tala_SlotPhom$showPhom(cards, phomId, ownerId) {
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        /// <param name="ownerId" type="Number" integer="true">
        /// </param>
        var p = null;
        p = this._getPhomByEatCard$1(cards);
        if (p == null) {
            p = this._getNextEmptyPhom$1();
        }
        p.set_width((cards.length - 1) * Games.Tala.VmgPhoneConstant.spaceInPhomW + Games.Tala.VmgPhoneConstant.cardWidth);
        p.set_height(Games.Tala.VmgPhoneConstant.cardHeight);
        p.set_visible(true);
        if (this._slot$1 === 0) {
            p.attachBigCards(new ZeroScript.Core.List(cards), phomId, ownerId, this._handX$1, this._handY$1);
        }
        else {
            p.attachCards(new ZeroScript.Core.List(cards), phomId, ownerId, this._handX$1, this._handY$1);
        }
    },
    
    _getPhomByEatCard$1: function Games_Tala_SlotPhom$_getPhomByEatCard$1(cards) {
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        /// <returns type="Games.Tala.PhomGroup"></returns>
        var list = new ZeroScript.Core.List(cards);
        for (var i = 0; i < 3; i++) {
            var p = this._phoms$1[i];
            if (list.contains(p.eatenCard)) {
                return p;
            }
        }
        return null;
    },
    
    gui: function Games_Tala_SlotPhom$gui(cards, fromSeat, phomId) {
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        /// <param name="fromSeat" type="Number" integer="true">
        /// </param>
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        var p = this._getPhomById$1(phomId);
        var x = Games.Tala.VmgPhoneConstant.handXs[fromSeat];
        var y = Games.Tala.VmgPhoneConstant.handYs[fromSeat];
        if (p == null) {
            Debug.writeLine('cannot find phomId = ' + phomId + ' @seat = ' + this._slot$1);
            return;
        }
        p.set_width(p.get_width() + cards.length * Games.Tala.VmgPhoneConstant.cardWidth);
        p.attachCards(new ZeroScript.Core.List(cards), phomId, p.ownerId, x, y);
    },
    
    eat: function Games_Tala_SlotPhom$eat(card) {
        /// <param name="card" type="Number" integer="true">
        /// </param>
        var c = Games.Base.Components.CardSuite.instance.get(card);
        var phom = this._getNextEmptyPhom$1();
        phom.set_visible(true);
        phom.eatenCard = card;
        phom.attachCard(card, -1, -1, c.get_x(), c.get_y());
    },
    
    _getPhomById$1: function Games_Tala_SlotPhom$_getPhomById$1(phomId) {
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        /// <returns type="Games.Tala.PhomGroup"></returns>
        for (var i = 0; i < 3; i++) {
            var p = this._phoms$1[i];
            if (p.phomId === phomId) {
                return p;
            }
        }
        return null;
    },
    
    resetParams: function Games_Tala_SlotPhom$resetParams() {
        for (var i = 0; i < 3; i++) {
            this._phoms$1[i].set_visible(false);
            this._phoms$1[i].clearCards();
        }
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.Picker

Games.Tala.Picker = function Games_Tala_Picker(facedown, counter) {
    /// <param name="facedown" type="ZeroScript.Core.Games.Image">
    /// </param>
    /// <param name="counter" type="Object" domElement="true">
    /// </param>
    /// <field name="_fly$1" type="ZeroScript.Core.Games.ImageComponent">
    /// </field>
    /// <field name="_facedown$1" type="ZeroScript.Core.Games.Image">
    /// </field>
    /// <field name="_counter$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_hideCounter$1" type="Boolean">
    /// </field>
    Games.Tala.Picker.constructBase(this);
    this._facedown$1 = facedown;
    this._counter$1 = counter;
    this._hideCounter$1 = true;
}
Games.Tala.Picker.prototype = {
    _fly$1: null,
    _facedown$1: null,
    _counter$1: null,
    _hideCounter$1: false,
    
    loadContentCompleted: function Games_Tala_Picker$loadContentCompleted() {
        this._fly$1 = new ZeroScript.Core.Games.ImageComponent(this._facedown$1);
        this._fly$1.set_x(0);
        this._fly$1.set_y(0);
        this._fly$1.set_visible(false);
        this.add(this._fly$1);
        Games.Tala.Picker.callBase(this, 'loadContentCompleted');
    },
    
    get_count: function Games_Tala_Picker$get_count() {
        /// <value type="Number" integer="true"></value>
        return -1;
    },
    set_count: function Games_Tala_Picker$set_count(value) {
        /// <value type="Number" integer="true"></value>
        if (value > 0) {
            this._counter$1.innerText = (value < 10) ? '0' + value : value.toString();
            this.set_hideCounter(false);
        }
        else {
            this.set_hideCounter(true);
        }
        return value;
    },
    
    get_hideCounter: function Games_Tala_Picker$get_hideCounter() {
        /// <value type="Boolean"></value>
        return this._hideCounter$1;
    },
    set_hideCounter: function Games_Tala_Picker$set_hideCounter(value) {
        /// <value type="Boolean"></value>
        if (this._hideCounter$1 === value) {
            return;
        }
        this._hideCounter$1 = value;
        if (this._hideCounter$1) {
            ZeroScript.Core.DomHelper.visible(this._counter$1, false);
        }
        else {
            ZeroScript.Core.DomHelper.visible(this._counter$1, true);
        }
        this.needRedraw = true;
        return value;
    },
    
    flyTo: function Games_Tala_Picker$flyTo(toX, toY) {
        /// <param name="toX" type="Number" integer="true">
        /// </param>
        /// <param name="toY" type="Number" integer="true">
        /// </param>
        /// <returns type="ZeroScript.Core.Games.IAnimation"></returns>
        this._fly$1.set_visible(true);
        return this._fly$1.move(0, 0, toX - this.get_x(), toY - this.get_y(), 500);
    },
    
    internalDraw: function Games_Tala_Picker$internalDraw(canvas) {
        /// <param name="canvas" type="ZeroScript.Core.Games.ICanvas">
        /// </param>
        canvas.draw(this._facedown$1, 0, 0, this._facedown$1.width, this._facedown$1.height, 0, 1);
    },
    
    hideFly: function Games_Tala_Picker$hideFly() {
        this._fly$1.set_visible(false);
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.MobieResultPart

Games.Tala.MobieResultPart = function Games_Tala_MobieResultPart() {
    /// <field name="_root$1" type="ZeroScript.Core.JQuery.IJQuery">
    /// </field>
    /// <field name="_bus$1" type="ZeroScript.Core.IBus">
    /// </field>
    /// <field name="u" type="String" static="true">
    /// </field>
    /// <field name="uKhan" type="String" static="true">
    /// </field>
    /// <field name="mom" type="String" static="true">
    /// </field>
    /// <field name="uDen" type="String" static="true">
    /// </field>
    /// <field name="denLang" type="String" static="true">
    /// </field>
    /// <field name="empty" type="String" static="true">
    /// </field>
    /// <field name="_resultTexts$1" type="Object" static="true">
    /// </field>
    Games.Tala.MobieResultPart.constructBase(this);
}
Games.Tala.MobieResultPart.prototype = {
    _root$1: null,
    _bus$1: null,
    
    initPart: function Games_Tala_MobieResultPart$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        this._root$1 = ZeroScript.Core.JQuery.JQueryHelper.select('.game_score');
        this._bus$1 = container.get_bus();
        this._bus$1.subcribe('GameEnd', Delegate.create(this, this._onGameEnd$1));
        this._bus$1.subcribe('YourCards', Delegate.create(this, this._onStart$1));
    },
    
    _onStart$1: function Games_Tala_MobieResultPart$_onStart$1(item) {
        /// <param name="item" type="Games.Tala.YourCards">
        /// </param>
        this._root$1.hide('');
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            var jQuery = this._root$1.find('.user_score');
            jQuery.find('.score').attr('class', 'score');
            jQuery.find('.money').html('');
        }
    },
    
    _onGameEnd$1: function Games_Tala_MobieResultPart$_onGameEnd$1(m) {
        /// <param name="m" type="Games.Base.Messages.GameEnd">
        /// </param>
        this._root$1.show(500, Delegate.create(this, function() {
        }));
        var result = m.result;
        var r = result;
        for (var rank = 0; rank < r.users.length; rank++) {
            var slot = r.users[rank];
            var u = Games.Tala.TalaState.current.get_session().rawUsers[slot];
            if (isNullOrUndefined(u)) {
                continue;
            }
            var seat = Games.Tala.TalaState.current.getSeat(u.id);
            var playerDom = this._root$1.find('.player' + (seat + 1));
            playerDom.find('.score').attr('class', this._getClass$1(rank, r.finalUserScores[rank]));
            playerDom.find('.money').html(r.money[rank] + ' xu');
        }
    },
    
    _getClass$1: function Games_Tala_MobieResultPart$_getClass$1(rank, key) {
        /// <param name="rank" type="Number" integer="true">
        /// </param>
        /// <param name="key" type="String">
        /// </param>
        /// <returns type="String"></returns>
        if (Object.keyExists(Games.Tala.MobieResultPart._resultTexts$1, key)) {
            return 'score ' + Games.Tala.MobieResultPart._resultTexts$1[key];
        }
        var rs = [ 'nhat', 'nhi', 'ba', 'bet' ];
        return 'score ' + rs[rank];
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.ResultPart

Games.Tala.ResultPart = function Games_Tala_ResultPart() {
    /// <field name="_bus$2" type="ZeroScript.Core.IBus">
    /// </field>
    /// <field name="u" type="String" static="true">
    /// </field>
    /// <field name="uKhan" type="String" static="true">
    /// </field>
    /// <field name="mom" type="String" static="true">
    /// </field>
    /// <field name="uDen" type="String" static="true">
    /// </field>
    /// <field name="denLang" type="String" static="true">
    /// </field>
    /// <field name="leaveGame" type="String" static="true">
    /// </field>
    /// <field name="empty" type="String" static="true">
    /// </field>
    /// <field name="_resultTexts$2" type="Object" static="true">
    /// </field>
    Games.Tala.ResultPart.constructBase(this);
}
Games.Tala.ResultPart.prototype = {
    _bus$2: null,
    
    initPart: function Games_Tala_ResultPart$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        this._bus$2 = container.get_bus();
        this._bus$2.subcribe('GameEnd', Delegate.create(this, this._onGameEnd$2));
    },
    
    _onGameEnd$2: function Games_Tala_ResultPart$_onGameEnd$2(m) {
        /// <param name="m" type="Games.Base.Messages.GameEnd">
        /// </param>
        var r = m.result;
        var result = this._normalizeGameResult$2(r);
        var d = {};
        d['data'] = result.toArray();
        var tmp = TemplateEngine.parseTemplate(document.getElementById('template_endGameActivity').innerHTML);
        var text = tmp.generate(d);
        this.appendResult(text);
    },
    
    _normalizeGameResult$2: function Games_Tala_ResultPart$_normalizeGameResult$2(result) {
        /// <param name="result" type="Games.Base.Messages.BaseGameResult">
        /// </param>
        /// <returns type="ZeroScript.Core.List"></returns>
        var r = result;
        var list = new ZeroScript.Core.List();
        for (var rank = 0; rank < r.users.length; rank++) {
            var slot = r.users[rank];
            var u = Games.Tala.TalaState.current.get_session().rawUsers[slot];
            if (isNullOrUndefined(u)) {
                continue;
            }
            var a = new Games.Base.Messages.UserResult();
            a.user = u;
            a.exp = r.experiences[rank] + 'exp';
            a.money = r.money[rank];
            a.reason = this._resultToText$2(r.finalUserScores[rank]);
            list.add(a);
        }
        return list;
    },
    
    _resultToText$2: function Games_Tala_ResultPart$_resultToText$2(key) {
        /// <param name="key" type="String">
        /// </param>
        /// <returns type="String"></returns>
        if (!isNaN(key)) {
            return key + '\u0111';
        }
        if (Object.keyExists(Games.Tala.ResultPart._resultTexts$2, key)) {
            return Games.Tala.ResultPart._resultTexts$2[key];
        }
        return key;
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.SlotCard

Games.Tala.SlotCard = function Games_Tala_SlotCard(slot) {
    /// <param name="slot" type="Number" integer="true">
    /// </param>
    /// <field name="_slot$1" type="Number" integer="true">
    /// </field>
    /// <field name="_handX$1" type="Number" integer="true">
    /// </field>
    /// <field name="_handY$1" type="Number" integer="true">
    /// </field>
    /// <field name="_holder$1" type="Games.Base.Components.FacedownHolder">
    /// </field>
    Games.Tala.SlotCard.constructBase(this);
    this._slot$1 = slot;
    this._handX$1 = Games.Tala.VmgPhoneConstant.handXs[slot];
    this._handY$1 = Games.Tala.VmgPhoneConstant.handYs[slot];
}
Games.Tala.SlotCard.prototype = {
    _slot$1: 0,
    _handX$1: 0,
    _handY$1: 0,
    _holder$1: null,
    
    loadContent: function Games_Tala_SlotCard$loadContent() {
        Games.Tala.SlotCard.callBase(this, 'loadContent');
        var faceDownH = this.get_container().get_contentManager().createImageFromUrl('_Resources/TaLa/img/facedown.png');
        this._holder$1 = new Games.Base.Components.FacedownHolder(Games.Base.Components.CardSuite.instance.get_faceDownImage(), faceDownH, Games.Tala.VmgPhoneConstant.space, Games.Tala.VmgPhoneConstant.space, Games.Tala.VmgPhoneConstant.spaceInPhomW, Games.Tala.VmgPhoneConstant.spaceInPhomH, 10, Games.Tala.VmgPhoneConstant.handDirects[this._slot$1]);
        this._holder$1.set_size(0);
        this._holder$1.set_visible(true);
        this._holder$1.set_x(this._handX$1);
        this._holder$1.set_y(this._handY$1);
        this.add(this._holder$1);
    },
    
    puzzle: function Games_Tala_SlotCard$puzzle() {
        this._holder$1.puzzle(9);
    },
    
    attack: function Games_Tala_SlotCard$attack(count) {
        /// <param name="count" type="Number" integer="true">
        /// </param>
        this._holder$1.set_size(this._holder$1.get_size() - count);
    },
    
    resetParams: function Games_Tala_SlotCard$resetParams() {
        this._holder$1.set_size(0);
        this._holder$1.set_x(this._handX$1);
        this._holder$1.set_y(this._handY$1);
    },
    
    showCards: function Games_Tala_SlotCard$showCards(cards) {
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        this._holder$1.set_size(0);
        this._holder$1.flip(cards);
    },
    
    pick: function Games_Tala_SlotCard$pick(seat) {
        /// <param name="seat" type="Number" integer="true">
        /// </param>
        this._holder$1.set_size(this._holder$1.get_size() + 1);
    },
    
    eat: function Games_Tala_SlotCard$eat(card) {
        /// <param name="card" type="Number" integer="true">
        /// </param>
        this._holder$1.set_size(this._holder$1.get_size() + 1);
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.GameMenu

Games.Tala.GameMenu = function Games_Tala_GameMenu() {
    /// <field name="_startBtn$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_quitBtn$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_joinBtn$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_standUpBtn$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_themeBtn$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_joinPrivateSessionTemplate$1" type="ZeroScript.Core.Templates.ITemplate">
    /// </field>
    /// <field name="_chatBtn$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_container$1" type="ZeroScript.Core.Parts.IPartContainer">
    /// </field>
    /// <field name="_bus$1" type="ZeroScript.Core.IBus">
    /// </field>
    Games.Tala.GameMenu.constructBase(this);
}
Games.Tala.GameMenu.prototype = {
    _startBtn$1: null,
    _quitBtn$1: null,
    _joinBtn$1: null,
    _standUpBtn$1: null,
    _themeBtn$1: null,
    _joinPrivateSessionTemplate$1: null,
    _chatBtn$1: null,
    _container$1: null,
    _bus$1: null,
    
    initPart: function Games_Tala_GameMenu$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        this._container$1 = container;
        this._joinPrivateSessionTemplate$1 = TemplateEngine.parseTemplate(document.getElementById('tmp_join_private_session').innerHTML);
        this._startBtn$1 = document.getElementById('start0');
        this._quitBtn$1 = document.getElementById('button_quit');
        this._joinBtn$1 = document.getElementById('join_btn');
        this._standUpBtn$1 = document.getElementById('button_standup');
        this._themeBtn$1 = document.getElementById('button_share');
        this._chatBtn$1 = document.getElementById('button_chat_mobie');
        ZeroScript.Core.DomHelper.visible(this._themeBtn$1, false);
        EventHelper.attachEvent(this._startBtn$1, EventHelper.click, Delegate.create(this, this._onStartClick$1));
        EventHelper.attachEvent(this._quitBtn$1, EventHelper.click, Delegate.create(this, this._onQuitClick$1));
        EventHelper.attachEvent(this._joinBtn$1, EventHelper.click, Delegate.create(this, this._onJoinClick$1));
        EventHelper.attachEvent(this._standUpBtn$1, EventHelper.click, Delegate.create(this, this._onStandUpClick$1));
        if (this._chatBtn$1 != null) {
            ZeroScript.Core.DomHelper.visible(this._chatBtn$1, true);
            EventHelper.attachEvent(this._chatBtn$1, EventHelper.click, Delegate.create(this, this._onChatClick$1));
        }
        var chat = ZeroScript.Core.JQuery.JQueryHelper.select('.chat');
        if (chat != null) {
            if (chat.hasClass('hideByPhone')) {
                chat.removeClass('hideByPhone');
                chat.addClass('hidden');
            }
        }
        this._bus$1 = this._container$1.get_bus();
        this._bus$1.subcribe('ClientStandUp', Delegate.create(this, this._onStandUp$1));
        this._bus$1.subcribe('JoinSessionResponse', Delegate.create(this, this._onJoinResponse$1));
        this._bus$1.subcribe('YourCards', Delegate.create(this, this._onGameStart$1));
        this._bus$1.subcribe('GameEnd', Delegate.create(this, this._onGameEnd$1));
        this._bus$1.subcribe('ChangeHost', Delegate.create(this, this._onChangeHost$1));
        this._bus$1.subcribe('PlayerJoinOpenSession', Delegate.create(this, this._onPlayerJoin$1));
        this._bus$1.subcribe('ClientLeaveOpenSession', Delegate.create(this, this._onPlayerLeaveOpenSession$1));
    },
    
    _onChatClick$1: function Games_Tala_GameMenu$_onChatClick$1(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        var chat = ZeroScript.Core.JQuery.JQueryHelper.select('.chat');
        if (chat.hasClass('hidden')) {
            chat.removeClass('hidden');
        }
        else {
            chat.addClass('hidden');
        }
    },
    
    _onPlayerLeaveOpenSession$1: function Games_Tala_GameMenu$_onPlayerLeaveOpenSession$1(item) {
        /// <param name="item" type="Games.Base.Messages.ClientLeaveOpenSession">
        /// </param>
        this._maybeDisplayJoinBtn$1();
    },
    
    _onPlayerJoin$1: function Games_Tala_GameMenu$_onPlayerJoin$1(item) {
        /// <param name="item" type="Games.Base.Messages.PlayerJoinOpenSession">
        /// </param>
        this._maybeDisplayJoinBtn$1();
    },
    
    _onChangeHost$1: function Games_Tala_GameMenu$_onChangeHost$1(item) {
        /// <param name="item" type="Games.Base.Messages.ChangeHost">
        /// </param>
        this._maybeDisplayStart$1();
    },
    
    _onGameEnd$1: function Games_Tala_GameMenu$_onGameEnd$1(m) {
        /// <param name="m" type="Games.Base.Messages.GameEnd">
        /// </param>
        this._maybeDisplayJoinBtn$1();
        this._maybeDisplayStart$1();
        this._maybeDisplayStandUpBtn$1();
    },
    
    _maybeDisplayStart$1: function Games_Tala_GameMenu$_maybeDisplayStart$1() {
        if (Games.Tala.TalaState.current.host === Global.get_user().id && Games.Tala.TalaState.current.get_hasOpenSlot() && !Games.Tala.TalaState.current.get_isPlaying()) {
            window.setTimeout(Delegate.create(this, function() {
                if (Games.Tala.TalaState.current.get_isPlaying()) {
                    return;
                }
                ZeroScript.Core.DomHelper.visible(this._startBtn$1, true);
            }), 7000);
        }
    },
    
    _onGameStart$1: function Games_Tala_GameMenu$_onGameStart$1(obj) {
        /// <param name="obj" type="Games.Tala.YourCards">
        /// </param>
        ZeroScript.Core.DomHelper.visible(this._joinBtn$1, false);
        ZeroScript.Core.DomHelper.visible(this._startBtn$1, false);
        this._maybeDisplayStandUpBtn$1();
    },
    
    _onJoinResponse$1: function Games_Tala_GameMenu$_onJoinResponse$1(m) {
        /// <param name="m" type="Games.Base.Messages.JoinSessionRespond">
        /// </param>
        if (GameError.isOkie(m.error)) {
            ZeroScript.Core.DomHelper.visible(this._joinBtn$1, false);
            ZeroScript.Core.DomHelper.visible(this._startBtn$1, false);
            this._maybeDisplayStandUpBtn$1();
        }
    },
    
    _onStandUp$1: function Games_Tala_GameMenu$_onStandUp$1(obj) {
        /// <param name="obj" type="Object">
        /// </param>
        this._maybeDisplayJoinBtn$1();
        this._maybeDisplayStart$1();
        this._maybeDisplayStandUpBtn$1();
    },
    
    _onStandUpClick$1: function Games_Tala_GameMenu$_onStandUpClick$1(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        Games.Base.GameRequest.send('StandUp.htm');
    },
    
    _onJoinClick$1: function Games_Tala_GameMenu$_onJoinClick$1(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        var session = Games.Tala.TalaState.current.get_session();
        if (session.isPrivate) {
            Games.Base.MessageBox.form('Th\u00f4ng b\u00e1o', this._joinPrivateSessionTemplate$1.generate(session), Delegate.create(this, function(form) {
                if (!session.isPlaying) {
                    var password = form.get_item('password');
                    Games.Base.GameRequest.send('ViewerJoinSession.htm', 'id', session.id, 'password', password);
                }
                form.close.invoke();
            }), null);
        }
        else {
            Games.Base.GameRequest.send('ViewerJoinSession.htm', 'id', session.id, 'password', String.Empty);
        }
    },
    
    _onQuitClick$1: function Games_Tala_GameMenu$_onQuitClick$1(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        this._bus$1.publish('navigator.backToSession', new Games.Parts.Common.NavigatorParams(Global.get_gameId(), Global.get_channel().id));
    },
    
    _onStartClick$1: function Games_Tala_GameMenu$_onStartClick$1(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        Games.Base.GameRequest.send('StartGame.htm');
    },
    
    active: function Games_Tala_GameMenu$active() {
        this._maybeDisplayJoinBtn$1();
        this._maybeDisplayStart$1();
        this._maybeDisplayStandUpBtn$1();
    },
    
    _maybeDisplayJoinBtn$1: function Games_Tala_GameMenu$_maybeDisplayJoinBtn$1() {
        var visible = Games.Tala.TalaState.current.get_hasOpenSlot() && Games.Tala.TalaState.current.get_isViewer() && Games.Tala.TalaState.current.host !== Global.get_user().id && !Games.Tala.TalaState.current.get_session().isPlaying;
        ZeroScript.Core.DomHelper.visible(this._joinBtn$1, visible);
    },
    
    _maybeDisplayStandUpBtn$1: function Games_Tala_GameMenu$_maybeDisplayStandUpBtn$1() {
        var visible = !Games.Tala.TalaState.current.get_isViewer();
        ZeroScript.Core.DomHelper.visible(this._standUpBtn$1, visible);
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.DevilFishGameResult

Games.Tala.DevilFishGameResult = function Games_Tala_DevilFishGameResult() {
    /// <field name="a" type="Array" elementType="Number" elementInteger="true">
    /// </field>
    /// <field name="b" type="Array" elementType="Number" elementInteger="true">
    /// </field>
    /// <field name="c" type="Array" elementType="Number" elementInteger="true">
    /// </field>
    /// <field name="d" type="Array" elementType="Number" elementInteger="true">
    /// </field>
    /// <field name="uPhoms" type="Array" elementType="Array">
    /// </field>
    /// <field name="finalUserScores" type="Array" elementType="String">
    /// </field>
    Games.Tala.DevilFishGameResult.constructBase(this);
}
Games.Tala.DevilFishGameResult.prototype = {
    a: null,
    b: null,
    c: null,
    d: null,
    uPhoms: null,
    finalUserScores: null
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.DfAction

Games.Tala.DfAction = function Games_Tala_DfAction() {
    /// <field name="startGame" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="pick" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="move" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="liveOn" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="show" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="eat" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="type" type="Number" integer="true">
    /// </field>
}
Games.Tala.DfAction.prototype = {
    type: 0
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.DfGameError

Games.Tala.DfGameError = function Games_Tala_DfGameError() {
    /// <field name="haDauKhongDuocGui" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="anLao" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="guiKhongDungPhom" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="khongDuocDanhCardDaAn" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="haKhongDungPhom" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="chuaDuocHa" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="khongDuocGuiCardDaAn" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="cardsHaPhaiLaPhom" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="khongCoPhomKhongDuocGui" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="anHoacBocRoiKhongDuocAnNua" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="anRoiKhongDuocAnNua" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="bocRoiKhongDuocAnNua" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="invalidActionBoc" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="invalidActionHa" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="invalidActionU" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="playerDoesntHaveOneOfTheseCards" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="khongDuocAnQua3Cards" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="khongDuocAnCardCuaQuitter" type="Number" integer="true" static="true">
    /// </field>
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.DfUserResult

Games.Tala.DfUserResult = function Games_Tala_DfUserResult() {
    /// <field name="reason" type="String">
    /// </field>
    Games.Tala.DfUserResult.constructBase(this);
}
Games.Tala.DfUserResult.prototype = {
    reason: null
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.PlayerAttack

Games.Tala.PlayerAttack = function Games_Tala_PlayerAttack(userId, card) {
    /// <param name="userId" type="Number" integer="true">
    /// </param>
    /// <param name="card" type="Number" integer="true">
    /// </param>
    /// <field name="card" type="Number" integer="true">
    /// </field>
    /// <field name="userId" type="Number" integer="true">
    /// </field>
    this.userId = userId;
    this.card = card;
}
Games.Tala.PlayerAttack.prototype = {
    card: 0,
    userId: 0
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.RotateCardData

Games.Tala.RotateCardData = function Games_Tala_RotateCardData(fromSeat, toSeat) {
    /// <param name="fromSeat" type="Number" integer="true">
    /// </param>
    /// <param name="toSeat" type="Number" integer="true">
    /// </param>
    /// <field name="fromSeat" type="Number" integer="true">
    /// </field>
    /// <field name="toSeat" type="Number" integer="true">
    /// </field>
    this.fromSeat = fromSeat;
    this.toSeat = toSeat;
}
Games.Tala.RotateCardData.prototype = {
    fromSeat: 0,
    toSeat: 0
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.PlayerPick

Games.Tala.PlayerPick = function Games_Tala_PlayerPick(userId) {
    /// <param name="userId" type="Number" integer="true">
    /// </param>
    /// <field name="userId" type="Number" integer="true">
    /// </field>
    this.userId = userId;
}
Games.Tala.PlayerPick.prototype = {
    userId: 0
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.SlotPart

Games.Tala.SlotPart = function Games_Tala_SlotPart() {
    /// <field name="_slots$1" type="Array" elementType="SlotCard">
    /// </field>
    /// <field name="_cardInHand$1" type="Games.Tala.VmgPhoneCardInHand">
    /// </field>
    /// <field name="_bus$1" type="ZeroScript.Core.IBus">
    /// </field>
    this._slots$1 = new Array(Games.Tala.TalaState.maxPlayers);
    Games.Tala.SlotPart.constructBase(this);
}
Games.Tala.SlotPart.prototype = {
    _cardInHand$1: null,
    _bus$1: null,
    
    initPart: function Games_Tala_SlotPart$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        this._bus$1 = container.get_bus();
        this._bus$1.subcribe('YourCards', Delegate.create(this, this._onGameStart$1));
        this._bus$1.subcribe('GameEnd', Delegate.create(this, this._onGameEnd$1));
        this._bus$1.subcribe('DevilFishPickResponse', Delegate.create(this, this._onPickResponse$1));
        this._bus$1.subcribe('DevilFishEatResponse', Delegate.create(this, this._onEatResponse$1));
        this._bus$1.subcribe('DevilFishShowResponse', Delegate.create(this, this._onShowResponse$1));
        this._bus$1.subcribe('DevilFishLiveOnResponse', Delegate.create(this, this._onGuiResponse$1));
        this._bus$1.subcribe('player.attack', Delegate.create(this, this._onPlayerAttack$1));
        this._bus$1.subcribe('player.pick', Delegate.create(this, this._onPlayerPick$1));
        this._bus$1.subcribe('on.last.turn', Delegate.create(this, this._onLastTurn$1));
        this._bus$1.subcribe('player.leave.session', Delegate.create(this, this._onPlayerLeave$1));
    },
    
    _onPlayerLeave$1: function Games_Tala_SlotPart$_onPlayerLeave$1(userId) {
        /// <param name="userId" type="Number" integer="true">
        /// </param>
        if (userId === Global.get_user().id) {
            return;
        }
        var seat = Games.Tala.TalaState.current.getSeat(userId);
        this._slots$1[seat].resetParams();
    },
    
    _onLastTurn$1: function Games_Tala_SlotPart$_onLastTurn$1(d) {
        /// <param name="d" type="Object">
        /// </param>
        this._cardInHand$1.multiSelect = true;
    },
    
    _onGuiResponse$1: function Games_Tala_SlotPart$_onGuiResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishLiveOnResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            Games.Base.MessageBox.notify('Kh\u00f4ng g\u1eedi \u0111\u01b0\u1ee3c b\u00e0i!');
            return;
        }
        this._bus$1.publish('ext.player.gui', null);
        var seat = Games.Tala.TalaState.current.getSeat(m.senderId);
        if (seat === 0) {
            this._removeCardsInHand$1(m.cards);
        }
        else {
            this._slots$1[seat].attack(m.cards.length);
        }
    },
    
    _onShowResponse$1: function Games_Tala_SlotPart$_onShowResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishShowResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            Games.Base.MessageBox.notify('Kh\u00f4ng h\u1ea1 \u0111\u01b0\u1ee3c b\u00e0i!');
            return;
        }
        this._bus$1.publish('ext.player.ha', null);
        var seat = Games.Tala.TalaState.current.getSeat(m.senderId);
        if (seat === 0) {
            var cards = m.cards;
            this._cardInHand$1.handX += Games.Tala.VmgPhoneConstant.spaceInHand * cards.length;
            this._removeCardsInHand$1(cards);
        }
        else {
            this._slots$1[seat].attack(m.cards.length);
        }
    },
    
    _removeCardsInHand$1: function Games_Tala_SlotPart$_removeCardsInHand$1(cards) {
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        var list = this._cardInHand$1.get_cards();
        for (var i = 0; i < cards.length; i++) {
            list.remove(cards[i]);
        }
        this._cardInHand$1.quickResetCards();
    },
    
    _onEatResponse$1: function Games_Tala_SlotPart$_onEatResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishEatResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            Games.Base.MessageBox.notify('Kh\u00f4ng \u0103n \u0111\u01b0\u1ee3c!');
            return;
        }
        var music = (m.anChot) ? 'ext.player.anchot' : 'ext.player.an';
        this._bus$1.publish(music, null);
        var seat = Games.Tala.TalaState.current.getSeat(m.senderId);
        if (seat === 0 || m.senderId === 0) {
            var smallCard = Games.Base.Components.CardSuite.instance.get(m.card);
            smallCard.set_visible(false);
            var card = Games.Tala.VmgPhoneCardSuite.instance.get(m.card);
            this._addCardToHand$1(card, smallCard.get_x(), smallCard.get_y()).continueWith(Delegate.create(this, function(c) {
                card.set_marked((Games.Tala.TalaState.current.get_isViewer()) ? false : true);
            }));
        }
        else {
            this._slots$1[seat].eat(m.card);
        }
    },
    
    _onPlayerPick$1: function Games_Tala_SlotPart$_onPlayerPick$1(d) {
        /// <param name="d" type="Games.Tala.PlayerPick">
        /// </param>
        var seat = Games.Tala.TalaState.current.getSeat(d.userId);
        if (seat < 0) {
            seat = Games.Tala.TalaState.current.getRawSeat(d.userId);
        }
        this._slots$1[seat].pick(seat);
    },
    
    _onPickResponse$1: function Games_Tala_SlotPart$_onPickResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishPickResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            return;
        }
        var card = Games.Tala.VmgPhoneCardSuite.instance.get(m.card);
        this._addCardToHand$1(card, Games.Tala.VmgPhoneConstant.pickX, Games.Tala.VmgPhoneConstant.pickY);
    },
    
    _addCardToHand$1: function Games_Tala_SlotPart$_addCardToHand$1(card, fromX, fromY) {
        /// <param name="card" type="Games.Base.Components.Card">
        /// </param>
        /// <param name="fromX" type="Number" integer="true">
        /// </param>
        /// <param name="fromY" type="Number" integer="true">
        /// </param>
        /// <returns type="ZeroScript.Core.Games.IAnimation"></returns>
        var cards = this._cardInHand$1.get_cards();
        cards.add(card.get_cardId());
        var x = (cards.get_count() - 1) * Games.Tala.VmgPhoneConstant.bigSpaceInHand + this._cardInHand$1.handX;
        var y = this._cardInHand$1.handY;
        card.bringToFront();
        return card.move(fromX, fromY, x, y, 500);
    },
    
    active: function Games_Tala_SlotPart$active() {
        this._cardInHand$1.initCardEvents();
    },
    
    inActive: function Games_Tala_SlotPart$inActive() {
    },
    
    _onGameEnd$1: function Games_Tala_SlotPart$_onGameEnd$1(m) {
        /// <param name="m" type="Games.Base.Messages.GameEnd">
        /// </param>
        var r = m.result;
        this._flipCardInHand$1(r.users[0], r.a);
        this._flipCardInHand$1(r.users[1], r.b);
        this._flipCardInHand$1(r.users[2], r.c);
        this._flipCardInHand$1(r.users[3], r.d);
    },
    
    _flipCardInHand$1: function Games_Tala_SlotPart$_flipCardInHand$1(playIndex, cards) {
        /// <param name="playIndex" type="Number" integer="true">
        /// </param>
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        if (Games.Tala.TalaState.current.get_session().users[playIndex] == null) {
            return;
        }
        var seat = Games.Tala.TalaState.current.toSeat(playIndex);
        if (seat < 0) {
            return;
        }
        if (seat === 0 && !Games.Tala.TalaState.current.get_isViewer()) {
            return;
        }
        this._slots$1[seat].showCards(cards);
    },
    
    _onPlayerAttack$1: function Games_Tala_SlotPart$_onPlayerAttack$1(d) {
        /// <param name="d" type="Games.Tala.PlayerAttack">
        /// </param>
        var seat = Games.Tala.TalaState.current.getSeat(d.userId);
        if (seat < 0) {
            return;
        }
        this._playerAttack$1(seat, d.card);
        this._bus$1.publish('ext.throw.card', null);
    },
    
    _playerAttack$1: function Games_Tala_SlotPart$_playerAttack$1(seat, card) {
        /// <param name="seat" type="Number" integer="true">
        /// </param>
        /// <param name="card" type="Number" integer="true">
        /// </param>
        if (seat === 0) {
            var cards = this._cardInHand$1.get_cards();
            cards.remove(card);
            this._cardInHand$1.quickResetCards();
        }
        else {
            this._slots$1[seat].attack(1);
        }
    },
    
    loadContent: function Games_Tala_SlotPart$loadContent() {
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            this._slots$1[i] = new Games.Tala.SlotCard(i);
            var slot = this._slots$1[i];
            slot.set_x(0);
            slot.set_y(0);
            slot.set_width(this.get_width());
            slot.set_height(this.get_height());
            this.add(slot);
        }
        this._cardInHand$1 = new Games.Tala.VmgPhoneCardInHand(Games.Tala.VmgPhoneConstant.bigSpaceInHand, Games.Tala.VmgPhoneConstant.cardInHandX, Games.Tala.VmgPhoneConstant.cardInHandY);
        this._cardInHand$1.set_x(Games.Tala.VmgPhoneConstant.cardInHandX);
        this._cardInHand$1.set_y(Games.Tala.VmgPhoneConstant.cardInHandY);
        this._cardInHand$1.set_width(this.get_width());
        this._cardInHand$1.set_height(this.get_height());
        this.add(this._cardInHand$1);
        Games.Tala.SlotPart.callBase(this, 'loadContent');
    },
    
    _onGameStart$1: function Games_Tala_SlotPart$_onGameStart$1(m) {
        /// <param name="m" type="Games.Tala.YourCards">
        /// </param>
        this._resetParams$1();
        this._chiaBai$1(m);
    },
    
    _resetParams$1: function Games_Tala_SlotPart$_resetParams$1() {
        this._cardInHand$1.handX = Games.Tala.VmgPhoneConstant.cardInHandX;
        this._cardInHand$1.multiSelect = false;
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            this._slots$1[i].resetParams();
        }
    },
    
    _chiaBai$1: function Games_Tala_SlotPart$_chiaBai$1(m) {
        /// <param name="m" type="Games.Tala.YourCards">
        /// </param>
        Games.Base.Components.CardSuite.instance.resetAllCards();
        Games.Tala.VmgPhoneCardSuite.instance.resetAllCards();
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            var user = Games.Tala.TalaState.current.get_session().users[i];
            if (isNullOrUndefined(user)) {
                continue;
            }
            var seat = Games.Tala.TalaState.current.getSeat(user.id);
            if (seat === 0 && Games.Tala.TalaState.current.get_currentUserIsPlayer()) {
                this._cardInHand$1.set_cards(new ZeroScript.Core.List(m.cards));
                this._cardInHand$1.chiaBai();
            }
            else {
                this._slots$1[seat].puzzle();
            }
        }
    },
    
    get_component: function Games_Tala_SlotPart$get_component() {
        /// <value type="ZeroScript.Core.Games.IComponent"></value>
        return this;
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.PlayerPart

Games.Tala.PlayerPart = function Games_Tala_PlayerPart() {
    /// <field name="_slots$1" type="Array" elementType="PlayerView">
    /// </field>
    /// <field name="_bus$1" type="ZeroScript.Core.IBus">
    /// </field>
    Games.Tala.PlayerPart.constructBase(this);
}
Games.Tala.PlayerPart.prototype = {
    _slots$1: null,
    _bus$1: null,
    
    get_state: function Games_Tala_PlayerPart$get_state() {
        /// <value type="Games.Tala.TalaState"></value>
        return Games.Tala.TalaState.current;
    },
    
    initPart: function Games_Tala_PlayerPart$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        this._bus$1 = container.get_bus();
        this._bus$1.subcribe('PlayerJoinOpenSession', Delegate.create(this, this._onPlayerJoin$1));
        this._bus$1.subcribe('JoinSessionResponse', Delegate.create(this, this._onJoinResponse$1));
        this._bus$1.subcribe('GameEnd', Delegate.create(this, this._onGameEnd$1));
        this._bus$1.subcribe('slot.updated', Delegate.create(this, this._onSlotUpdated$1));
    },
    
    active: function Games_Tala_PlayerPart$active() {
    },
    
    inActive: function Games_Tala_PlayerPart$inActive() {
    },
    
    _onGameEnd$1: function Games_Tala_PlayerPart$_onGameEnd$1(m) {
        /// <param name="m" type="Games.Base.Messages.GameEnd">
        /// </param>
    },
    
    _onJoinResponse$1: function Games_Tala_PlayerPart$_onJoinResponse$1(m) {
        /// <param name="m" type="Games.Base.Messages.JoinSessionRespond">
        /// </param>
        if (GameError.isOkie(m.error)) {
            this._updateSlots$1();
        }
    },
    
    _onPlayerJoin$1: function Games_Tala_PlayerPart$_onPlayerJoin$1(m) {
        /// <param name="m" type="Games.Base.Messages.PlayerJoinOpenSession">
        /// </param>
        this._updateSlots$1();
    },
    
    init: function Games_Tala_PlayerPart$init(container) {
        /// <param name="container" type="ZeroScript.Core.Games.IComponentContainer">
        /// </param>
        Games.Tala.PlayerPart.callBase(this, 'init', [ container ]);
        this._slots$1 = new Array(Games.Tala.TalaState.maxPlayers);
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            var slot = new Games.Tala.PlayerView(i, this._bus$1);
            this._slots$1[i] = slot;
        }
    },
    
    run: function Games_Tala_PlayerPart$run() {
        this._updateSlots$1();
    },
    
    get_component: function Games_Tala_PlayerPart$get_component() {
        /// <value type="ZeroScript.Core.Games.IComponent"></value>
        return this;
    },
    
    _onSlotUpdated$1: function Games_Tala_PlayerPart$_onSlotUpdated$1(text) {
        /// <param name="text" type="String">
        /// </param>
        this._updateSlots$1();
    },
    
    _updateSlots$1: function Games_Tala_PlayerPart$_updateSlots$1() {
        for (var i = 0; i < this._slots$1.length; i++) {
            this._slots$1[i].set_user(null);
        }
        for (var i = 0; i < this.get_state().get_session().users.length; i++) {
            var u = this.get_state().get_session().users[i];
            if (isNullOrUndefined(u)) {
                continue;
            }
            var seat = this.get_state().getSeat(u.id);
            var playerSlot = this._slots$1[seat];
            playerSlot.set_user(u);
            playerSlot.show();
            playerSlot.showHost(this.get_state().host === u.id);
        }
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.PlayerView

Games.Tala.PlayerView = function Games_Tala_PlayerView(slot, bus) {
    /// <param name="slot" type="Number" integer="true">
    /// </param>
    /// <param name="bus" type="ZeroScript.Core.IBus">
    /// </param>
    /// <field name="_userInfo" type="Object" domElement="true">
    /// </field>
    /// <field name="_name" type="Object" domElement="true">
    /// </field>
    /// <field name="_host" type="Object" domElement="true">
    /// </field>
    /// <field name="_avatar" type="Object" domElement="true">
    /// </field>
    /// <field name="_money" type="Object" domElement="true">
    /// </field>
    /// <field name="_level" type="Object" domElement="true">
    /// </field>
    /// <field name="_bus" type="ZeroScript.Core.IBus">
    /// </field>
    /// <field name="_user" type="Games.Base.Data.User">
    /// </field>
    this._bus = bus;
    var root = ZeroScript.Core.JQuery.JQueryHelper.select('#user_info' + slot);
    this._userInfo = document.getElementById('user_info' + slot);
    this._name = root.find('.name')[0];
    this._avatar = root.find('.avatar img')[0];
    this._host = root.find('.host_user')[0];
    this._money = root.find('.money')[0];
    this._level = root.find('.timebar .timebar_level')[0];
    EventHelper.attachEvent(this._avatar, EventHelper.click, Delegate.create(this, this._onClick));
    bus.subcribe('user.money', Delegate.create(this, this._onUpdateMoney));
    bus.subcribe('user.level', Delegate.create(this, this._onUpdateLevel));
    this.clear();
}
Games.Tala.PlayerView.prototype = {
    _userInfo: null,
    _name: null,
    _host: null,
    _avatar: null,
    _money: null,
    _level: null,
    _bus: null,
    _user: null,
    
    _onUpdateLevel: function Games_Tala_PlayerView$_onUpdateLevel(u) {
        /// <param name="u" type="Games.Base.Data.User">
        /// </param>
        if (this._user == null || u.id !== this._user.id) {
            return;
        }
        var level = u.statics.level;
        this._level.innerHTML = String.format('Level: <span>{0}</span>', level);
        var clazz = Math.floor(level / 10) * 10;
        this._level.className = String.format('timebar_level _{0}', clazz);
    },
    
    _onUpdateMoney: function Games_Tala_PlayerView$_onUpdateMoney(u) {
        /// <param name="u" type="Games.Base.Data.User">
        /// </param>
        if (this._user == null || u.id !== this._user.id) {
            return;
        }
        this._money.innerHTML = Format.compactCurrency(u.statics.money);
    },
    
    _onClick: function Games_Tala_PlayerView$_onClick(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        if (this._user == null) {
            return;
        }
        this._bus.publish('showProfile', this._user);
    },
    
    _displayMe: function Games_Tala_PlayerView$_displayMe(visible) {
        /// <param name="visible" type="Boolean">
        /// </param>
        ZeroScript.Core.DomHelper.visible(this._userInfo, visible);
    },
    
    get_user: function Games_Tala_PlayerView$get_user() {
        /// <value type="Games.Base.Data.User"></value>
        return this._user;
    },
    set_user: function Games_Tala_PlayerView$set_user(value) {
        /// <value type="Games.Base.Data.User"></value>
        this._user = value;
        var b = this._user != null;
        this._displayMe(b);
        if (b) {
            var users = [ this._user ];
            this._bus.publish('user.updateAvatars', users);
            this._bus.publish('user.updateProfiles', users);
            this._avatar.src = this._user.avatar;
            this._bus.publish('user.updateMoney', users);
            this._bus.publish('user.updateLevel', users);
        }
        this._name.innerHTML = (b) ? this._user.firstName : '';
        return value;
    },
    
    clear: function Games_Tala_PlayerView$clear() {
        this.set_user(null);
    },
    
    show: function Games_Tala_PlayerView$show() {
        ZeroScript.Core.DomHelper.visible(this._userInfo, true);
    },
    
    hide: function Games_Tala_PlayerView$hide() {
        ZeroScript.Core.DomHelper.visible(this._userInfo, false);
    },
    
    showHost: function Games_Tala_PlayerView$showHost(isHost) {
        /// <param name="isHost" type="Boolean">
        /// </param>
        ZeroScript.Core.DomHelper.visible(this._host, isHost);
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.VmgPhoneCardSuite

Games.Tala.VmgPhoneCardSuite = function Games_Tala_VmgPhoneCardSuite(image, faceDownImage, cardWidth, cardHeight, highLight, eat, marker) {
    /// <param name="image" type="ZeroScript.Core.Games.Image">
    /// </param>
    /// <param name="faceDownImage" type="ZeroScript.Core.Games.Image">
    /// </param>
    /// <param name="cardWidth" type="Number" integer="true">
    /// </param>
    /// <param name="cardHeight" type="Number" integer="true">
    /// </param>
    /// <param name="highLight" type="ZeroScript.Core.Games.Image">
    /// </param>
    /// <param name="eat" type="ZeroScript.Core.Games.Image">
    /// </param>
    /// <param name="marker" type="ZeroScript.Core.Games.Image">
    /// </param>
    /// <field name="instance" type="Games.Tala.VmgPhoneCardSuite" static="true">
    /// </field>
    Games.Tala.VmgPhoneCardSuite.constructBase(this, [ image, faceDownImage, cardWidth, cardHeight, highLight, eat, marker ]);
    Games.Tala.VmgPhoneCardSuite.instance = this;
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.VmgPhoneCardInHand

Games.Tala.VmgPhoneCardInHand = function Games_Tala_VmgPhoneCardInHand(space, handX, handY) {
    /// <param name="space" type="Number" integer="true">
    /// </param>
    /// <param name="handX" type="Number" integer="true">
    /// </param>
    /// <param name="handY" type="Number" integer="true">
    /// </param>
    /// <field name="_liftDuration$1" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="instance" type="Games.Tala.VmgPhoneCardInHand" static="true">
    /// </field>
    /// <field name="_sortMode$1" type="Games.Base.Components.SortMode">
    /// </field>
    /// <field name="_cards$1" type="ZeroScript.Core.List">
    /// </field>
    /// <field name="_space$1" type="Number" integer="true">
    /// </field>
    /// <field name="_mouseDown$1" type="Boolean">
    /// </field>
    /// <field name="_selectedCard$1" type="Number" integer="true">
    /// </field>
    /// <field name="_highLightCard$1" type="Games.Base.Components.Card">
    /// </field>
    /// <field name="handX" type="Number" integer="true">
    /// </field>
    /// <field name="handY" type="Number" integer="true">
    /// </field>
    /// <field name="multiSelect" type="Boolean">
    /// </field>
    /// <field name="attacking" type="Boolean">
    /// </field>
    this._sortMode$1 = Games.Base.Components.SortMode.valueClass;
    this._cards$1 = new ZeroScript.Core.List();
    Games.Tala.VmgPhoneCardInHand.constructBase(this);
    this._space$1 = space;
    this._selectedCard$1 = -1;
    this.handX = handX;
    this.handY = handY;
    Games.Tala.VmgPhoneCardInHand.instance = this;
}
Games.Tala.VmgPhoneCardInHand.prototype = {
    _space$1: 0,
    _mouseDown$1: false,
    _selectedCard$1: 0,
    _highLightCard$1: null,
    handX: 0,
    handY: 0,
    multiSelect: true,
    attacking: false,
    
    initCardEvents: function Games_Tala_VmgPhoneCardInHand$initCardEvents() {
        this.attacking = false;
        for (var i = 0; i < 52; i++) {
            var card = Games.Tala.VmgPhoneCardSuite.instance.get(i);
            card.add_mouseDown(Delegate.create(this, this._cardMouseDown$1));
            card.add_mouseOut(Delegate.create(this, this._cardMouseOut$1));
            card.add_mouseUp(Delegate.create(this, this._cardMouseUp$1));
            card.add_mouseMove(Delegate.create(this, this._cardMouseMove$1));
        }
    },
    
    get_cards: function Games_Tala_VmgPhoneCardInHand$get_cards() {
        /// <value type="ZeroScript.Core.List"></value>
        return this._cards$1;
    },
    set_cards: function Games_Tala_VmgPhoneCardInHand$set_cards(value) {
        /// <value type="ZeroScript.Core.List"></value>
        this._cards$1 = value;
        this._selectedCard$1 = -1;
        return value;
    },
    
    sort: function Games_Tala_VmgPhoneCardInHand$sort() {
        switch (this._sortMode$1) {
            case Games.Base.Components.SortMode.none:
            case Games.Base.Components.SortMode.classValue:
                this._sortMode$1 = Games.Base.Components.SortMode.valueClass;
                break;
            case Games.Base.Components.SortMode.valueClass:
                this._sortMode$1 = Games.Base.Components.SortMode.classValue;
                break;
        }
        Games.Base.Components.CardHelper.sortCard(this._sortMode$1, this._cards$1, true);
        this.quickResetCards();
    },
    
    quickResetCards: function Games_Tala_VmgPhoneCardInHand$quickResetCards() {
        if (this.attacking) {
            return;
        }
        for (var i = 0; i < this._cards$1.get_count(); i++) {
            var card = Games.Tala.VmgPhoneCardSuite.instance.get(this._cards$1.get_item(i));
            if (card.get_faceDown()) {
                card.set_faceDown(false);
            }
            card.bringToFront();
            card.moveTo(this.handX + i * this._space$1, this.handY, 400);
        }
    },
    
    chiaBai: function Games_Tala_VmgPhoneCardInHand$chiaBai() {
        this.sort();
        this.sort();
        for (var i = 0; i < this._cards$1.get_count(); i++) {
            var card = Games.Tala.VmgPhoneCardSuite.instance.get(this._cards$1.get_item(i));
            card.bringToFront();
            card.rotateAfterDelay(240, 360, 400, i * 80);
            var x = Games.Tala.VmgPhoneCardSuite.instance.get_parent().get_width() / 2;
            var y = (Games.Tala.VmgPhoneCardSuite.instance.get_parent().get_height() / 2);
            card.moveAfterDelay(x, y, this.handX + i * this._space$1, this.handY, 400, i * 80);
        }
    },
    
    getSelectedCards: function Games_Tala_VmgPhoneCardInHand$getSelectedCards() {
        /// <returns type="ZeroScript.Core.List"></returns>
        var list = new ZeroScript.Core.List();
        for (var i = 0; i < this._cards$1.get_count(); i++) {
            var card = Games.Tala.VmgPhoneCardSuite.instance.get(this._cards$1.get_item(i));
            if (card.get_y() < this.handY) {
                list.add(card.get_cardId());
            }
        }
        return list;
    },
    
    _cardMouseMove$1: function Games_Tala_VmgPhoneCardInHand$_cardMouseMove$1(sender, x, y) {
        /// <param name="sender" type="ZeroScript.Core.Games.IComponent">
        /// </param>
        /// <param name="x" type="Number" integer="true">
        /// </param>
        /// <param name="y" type="Number" integer="true">
        /// </param>
        var card = sender;
        if (!this._mouseDown$1) {
            return;
        }
        if (this._isMyCard$1(card.get_cardId())) {
            card.set_highLight(true);
            if (this._highLightCard$1 != null && this._highLightCard$1 !== card) {
                this._highLightCard$1.set_highLight(false);
            }
            this._highLightCard$1 = card;
        }
    },
    
    _cardMouseUp$1: function Games_Tala_VmgPhoneCardInHand$_cardMouseUp$1(sender, x, y) {
        /// <param name="sender" type="ZeroScript.Core.Games.IComponent">
        /// </param>
        /// <param name="x" type="Number" integer="true">
        /// </param>
        /// <param name="y" type="Number" integer="true">
        /// </param>
        var card = sender;
        if (!this._isMyCard$1(card.get_cardId())) {
            return;
        }
        if (card.get_cardId() !== this._selectedCard$1 && this._selectedCard$1 >= 0) {
            this._insert$1(card.get_cardId());
            this.quickResetCards();
            this._selectedCard$1 = -1;
        }
        this._mouseDown$1 = false;
    },
    
    _cardMouseOut$1: function Games_Tala_VmgPhoneCardInHand$_cardMouseOut$1(sender, x, y) {
        /// <param name="sender" type="ZeroScript.Core.Games.IComponent">
        /// </param>
        /// <param name="x" type="Number" integer="true">
        /// </param>
        /// <param name="y" type="Number" integer="true">
        /// </param>
        var card = sender;
        card.set_highLight(false);
    },
    
    _cardMouseDown$1: function Games_Tala_VmgPhoneCardInHand$_cardMouseDown$1(sender, x, y) {
        /// <param name="sender" type="ZeroScript.Core.Games.IComponent">
        /// </param>
        /// <param name="x" type="Number" integer="true">
        /// </param>
        /// <param name="y" type="Number" integer="true">
        /// </param>
        var card = sender;
        if (!this._isMyCard$1(card.get_cardId())) {
            return;
        }
        this._liftCard$1(card);
        this._mouseDown$1 = true;
    },
    
    _isMyCard$1: function Games_Tala_VmgPhoneCardInHand$_isMyCard$1(cardId) {
        /// <param name="cardId" type="Number" integer="true">
        /// </param>
        /// <returns type="Boolean"></returns>
        return this._cards$1.contains(cardId);
    },
    
    _liftCard$1: function Games_Tala_VmgPhoneCardInHand$_liftCard$1(card) {
        /// <param name="card" type="Games.Base.Components.Card">
        /// </param>
        if (card.get_y() >= this.handY) {
            this._selectedCard$1 = card.get_cardId();
            for (var i = 0; i < this._cards$1.get_count(); i++) {
                var c = Games.Tala.VmgPhoneCardSuite.instance.get(this._cards$1.get_item(i));
                c.bringToFront();
            }
            if (!this.multiSelect) {
                for (var i = 0; i < this._cards$1.get_count(); i++) {
                    var c = Games.Tala.VmgPhoneCardSuite.instance.get(this._cards$1.get_item(i));
                    c.moveTo(c.get_x(), this.get_y(), Games.Tala.VmgPhoneCardInHand._liftDuration$1);
                }
            }
            card.moveTo(card.get_x(), card.get_y() - 30, Games.Tala.VmgPhoneCardInHand._liftDuration$1);
            return;
        }
        this._selectedCard$1 = -1;
        card.moveTo(card.get_x(), this.handY, Games.Tala.VmgPhoneCardInHand._liftDuration$1);
    },
    
    _insert$1: function Games_Tala_VmgPhoneCardInHand$_insert$1(cardAtPointer) {
        /// <param name="cardAtPointer" type="Number" integer="true">
        /// </param>
        var index = -1;
        var indexOfSelectedCard = -1;
        for (var i = 0; i < this._cards$1.get_count(); i++) {
            if (this._cards$1.get_item(i) === cardAtPointer) {
                index = i;
            }
            if (this._cards$1.get_item(i) === this._selectedCard$1) {
                indexOfSelectedCard = i;
            }
        }
        this._cards$1.remove(this._selectedCard$1);
        if (indexOfSelectedCard > index) {
            index++;
        }
        this._cards$1.insertAt(index, this._selectedCard$1);
    },
    
    resetCards: function Games_Tala_VmgPhoneCardInHand$resetCards() {
        for (var i = 0; i < this._cards$1.get_count(); i++) {
            var card = Games.Tala.VmgPhoneCardSuite.instance.get(this._cards$1.get_item(i));
            card.bringToFront();
            if (card.get_y() !== this.handY) {
                card.moveTo(this.handX + i * this._space$1, this.handY, Games.Tala.VmgPhoneCardInHand._liftDuration$1);
            }
        }
        this._selectedCard$1 = -1;
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.TablePart

Games.Tala.TablePart = function Games_Tala_TablePart() {
    /// <field name="_baseImageUrl$1" type="String" static="true">
    /// </field>
    /// <field name="_highLightUrl$1" type="String" static="true">
    /// </field>
    /// <field name="_eatImgUrl$1" type="String" static="true">
    /// </field>
    /// <field name="_markerImgUrl$1" type="String" static="true">
    /// </field>
    /// <field name="_cardType$1" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="_eatCards$1" type="ZeroScript.Core.List">
    /// </field>
    /// <field name="_view$1" type="Games.Tala._tableView">
    /// </field>
    /// <field name="_phoms$1" type="Array" elementType="SlotPhom">
    /// </field>
    /// <field name="_allPhoms$1" type="Array" elementType="Phom">
    /// </field>
    /// <field name="_bus$1" type="ZeroScript.Core.IBus">
    /// </field>
    /// <field name="_phomExtractor$1" type="PhomExtractor">
    /// </field>
    /// <field name="_suggestedCard$1" type="Number" integer="true">
    /// </field>
    /// <field name="_selectedCard$1" type="Number" integer="true">
    /// </field>
    /// <field name="_phomShow$1" type="ZeroScript.Core.List">
    /// </field>
    /// <field name="_guis$1" type="ZeroScript.Core.List">
    /// </field>
    /// <field name="_rotateData$1" type="Games.Tala.RotateCardData">
    /// </field>
    /// <field name="_lastCard$1" type="Number" integer="true">
    /// </field>
    /// <field name="_hasPhom$1" type="Boolean">
    /// </field>
    this._phoms$1 = new Array(Games.Tala.TalaState.maxPlayers);
    this._allPhoms$1 = new Array(12);
    Games.Tala.TablePart.constructBase(this);
    this._phomExtractor$1 = new PhomExtractor();
}
Games.Tala.TablePart.prototype = {
    _eatCards$1: null,
    _view$1: null,
    _bus$1: null,
    _phomExtractor$1: null,
    _suggestedCard$1: 0,
    _selectedCard$1: 0,
    _phomShow$1: null,
    _guis$1: null,
    _rotateData$1: null,
    _lastCard$1: 0,
    _hasPhom$1: false,
    
    initPart: function Games_Tala_TablePart$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        this._bus$1 = container.get_bus();
        this._bus$1.subcribe('ClientDevilFishPick', Delegate.create(this, this._onClientPick$1));
        this._bus$1.subcribe('DevilFishPickResponse', Delegate.create(this, this._onPickResponse$1));
        this._bus$1.subcribe('YourCards', Delegate.create(this, this._onGameStart$1));
        this._bus$1.subcribe('GameEnd', Delegate.create(this, this._onGameEnd$1));
        this._bus$1.subcribe('DevilFishEatResponse', Delegate.create(this, this._onEatResponse$1));
        this._bus$1.subcribe('DevilFishShowResponse', Delegate.create(this, this._onShowResponse$1));
        this._bus$1.subcribe('DevilFishUResponse', Delegate.create(this, this._onUResponse$1));
        this._bus$1.subcribe('DevilFishLiveOnResponse', Delegate.create(this, this._onGuiResponse$1));
        this._bus$1.subcribe('player.attack', Delegate.create(this, this._onPlayerAttack$1));
        this._bus$1.subcribe('player.last.attack', Delegate.create(this, this._onLastAttack$1));
        this._bus$1.subcribe('player.show.phom', Delegate.create(this, this._onShowPhomOnly$1));
        this._bus$1.subcribe('require.rotate.card', Delegate.create(this, this._onRotate$1));
    },
    
    _onRotate$1: function Games_Tala_TablePart$_onRotate$1(d) {
        /// <param name="d" type="Games.Tala.RotateCardData">
        /// </param>
        this._rotateData$1 = d;
    },
    
    _onShowPhomOnly$1: function Games_Tala_TablePart$_onShowPhomOnly$1(d) {
        /// <param name="d" type="Object">
        /// </param>
        this._phomShow$1 = this._getPhoms$1();
        this._guis$1 = this._getGuis$1(this._phomShow$1);
        for (var i = 0; i < this._phomShow$1.get_count(); i++) {
            var p = this._phomShow$1.get_item(i);
            var arr = p.toArray();
            Games.Base.GameRequest.send('ShowPhom.htm', 'cards', arr);
        }
        for (var i = 0; i < this._guis$1.get_count(); i++) {
            var g = this._guis$1.get_item(i);
            if (isNullOrUndefined(g)) {
                continue;
            }
            Games.Base.GameRequest.send('LiveOn.htm', 'cards', [ g.get_card() ], 'phomId', g.get_phomId(), 'targetId', g.get_phomOwnerId());
        }
    },
    
    _onLastAttack$1: function Games_Tala_TablePart$_onLastAttack$1(d) {
        /// <param name="d" type="Games.Tala.PlayerAttack">
        /// </param>
        this._selectedCard$1 = d.card;
        this._phomShow$1 = this._getPhoms$1();
        this._guis$1 = this._getGuis$1(this._phomShow$1);
        var hasPhom = this._phomShow$1.get_count() > 0;
        var hasGui = this._hasPhom$1 && this._guiAble$1(this._guis$1);
        if (hasPhom || hasGui) {
            this._view$1.showSuggestPhomDialog(hasPhom, this._phomShow$1);
        }
        else {
            Games.Base.GameRequest.send('Move.htm', 'cards', [ this._selectedCard$1 ]);
        }
    },
    
    _guiAble$1: function Games_Tala_TablePart$_guiAble$1(guis) {
        /// <param name="guis" type="ZeroScript.Core.List">
        /// </param>
        /// <returns type="Boolean"></returns>
        for (var i = 0; i < guis.get_count(); i++) {
            var g = guis.get_item(i);
            if (g == null) {
                continue;
            }
            return true;
        }
        return false;
    },
    
    _getPhoms$1: function Games_Tala_TablePart$_getPhoms$1() {
        /// <returns type="ZeroScript.Core.List"></returns>
        var cards = Games.Tala.VmgPhoneCardInHand.instance.get_cards();
        var remainCards = new ZeroScript.Core.List(cards.toArray());
        if (this._selectedCard$1 >= 0) {
            remainCards.remove(this._selectedCard$1);
        }
        var phoms = this._phomExtractor$1.extract(remainCards.toArray(), this._eatCards$1.toArray());
        return phoms;
    },
    
    _onGameEnd$1: function Games_Tala_TablePart$_onGameEnd$1(m) {
        /// <param name="m" type="Games.Base.Messages.GameEnd">
        /// </param>
        this._hideSuggest$1();
        var r = m.result;
        if (this._hasPlayerU$1(r)) {
            var seat = Games.Tala.TalaState.current.getSeat(Games.Tala.TalaState.current.currentPlayer);
            for (var i = 0; i < r.uPhoms.length; i++) {
                var cards = r.uPhoms[i];
                this._phoms$1[seat].showPhom(cards, -1, -1);
            }
        }
    },
    
    _hasPlayerU$1: function Games_Tala_TablePart$_hasPlayerU$1(r) {
        /// <param name="r" type="Games.Tala.DevilFishGameResult">
        /// </param>
        /// <returns type="Boolean"></returns>
        for (var rank = 0; rank < r.finalUserScores.length; rank++) {
            var finalUserScore = r.finalUserScores[rank];
            if (finalUserScore.indexOf('U') >= 0) {
                return true;
            }
        }
        return false;
    },
    
    _onGuiResponse$1: function Games_Tala_TablePart$_onGuiResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishLiveOnResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            return;
        }
        var fromSeat = Games.Tala.TalaState.current.getSeat(Games.Tala.TalaState.current.currentPlayer);
        var toSeat = Games.Tala.TalaState.current.getSeat(m.targerId);
        this._phoms$1[toSeat].gui(m.cards, fromSeat, m.phomId);
    },
    
    _onUResponse$1: function Games_Tala_TablePart$_onUResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishUResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            Games.Base.MessageBox.notify('Ch\u01b0a \u00f9 \u0111\u01b0\u1ee3c!');
        }
    },
    
    _onShowResponse$1: function Games_Tala_TablePart$_onShowResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishShowResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            return;
        }
        var seat = Games.Tala.TalaState.current.getSeat(m.ownerId);
        if (seat === 0) {
            this._hasPhom$1 = true;
            this._phoms$1[seat].set_x(Games.Tala.VmgPhoneConstant.groupPhomX[seat]);
            for (var i = 0; i < m.cards.length; i++) {
                this._eatCards$1.remove(m.cards[i]);
            }
        }
        this._phoms$1[seat].showPhom(m.cards, m.phomId, m.ownerId);
        var phomSlot = this._getEmptyPhom$1();
        this._allPhoms$1[phomSlot] = new Games.Tala.Phom(new ZeroScript.Core.List(m.cards), m.phomId, m.ownerId);
    },
    
    _getEmptyPhom$1: function Games_Tala_TablePart$_getEmptyPhom$1() {
        /// <returns type="Number" integer="true"></returns>
        for (var slot = 0; slot < this._allPhoms$1.length; slot++) {
            if (this._allPhoms$1[slot].get_ownerId() === -1) {
                return slot;
            }
        }
        return -1;
    },
    
    _onEatResponse$1: function Games_Tala_TablePart$_onEatResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishEatResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            return;
        }
        this._hideSuggest$1();
        var id = (m.senderId === 0) ? Games.Tala.TalaState.current.currentPlayer : m.senderId;
        var currentSeat = Games.Tala.TalaState.current.getSeat(id);
        var previousSeat = Games.Tala.TalaState.current.getPreviousSeat(id);
        if (currentSeat === 0 || m.senderId === 0) {
            this._eatCards$1.add(m.card);
        }
        else {
            this._phoms$1[currentSeat].eat(m.card);
        }
        this._view$1.playerEat(previousSeat, m.card);
        if (this._rotateData$1 != null) {
            Debug.writeLine('Rotate from: ' + this._rotateData$1.fromSeat + ' to: ' + this._rotateData$1.toSeat);
            this._view$1.rotateCard(this._rotateData$1.fromSeat, this._rotateData$1.toSeat);
            this._rotateData$1 = null;
        }
    },
    
    _onGameStart$1: function Games_Tala_TablePart$_onGameStart$1(item) {
        /// <param name="item" type="Games.Tala.YourCards">
        /// </param>
        this._resetParams$1();
        var playerCount = 0;
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            var user = Games.Tala.TalaState.current.get_session().users[i];
            if (isNullOrUndefined(user)) {
                continue;
            }
            playerCount++;
        }
        var pickCount = Games.Tala.TalaState.current.getPickCardsCount(playerCount);
        this._view$1.set_pickCount(pickCount);
    },
    
    _resetParams$1: function Games_Tala_TablePart$_resetParams$1() {
        this._hasPhom$1 = false;
        this._lastCard$1 = -1;
        this._rotateData$1 = null;
        this._phomShow$1 = new ZeroScript.Core.List();
        this._guis$1 = new ZeroScript.Core.List();
        this._suggestedCard$1 = -1;
        this._selectedCard$1 = -1;
        this._eatCards$1 = new ZeroScript.Core.List();
        this._view$1.resetParams();
        for (var i = 0; i < this._phoms$1.length; i++) {
            this._phoms$1[i].resetParams();
            this._phoms$1[i].set_x(Games.Tala.VmgPhoneConstant.groupPhomX[i]);
        }
        for (var i = 0; i < this._allPhoms$1.length; i++) {
            this._allPhoms$1[i] = new Games.Tala.Phom(new ZeroScript.Core.List(), -1, -1);
        }
    },
    
    _onPickResponse$1: function Games_Tala_TablePart$_onPickResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishPickResponse">
        /// </param>
        this._view$1.set_pickCount(m.numOfRemainCards);
        this._hideSuggest$1();
    },
    
    _hideSuggest$1: function Games_Tala_TablePart$_hideSuggest$1() {
        this._hideSuggestedCard$1();
        this._view$1.suggestPick(false);
    },
    
    _onClientPick$1: function Games_Tala_TablePart$_onClientPick$1(m) {
        /// <param name="m" type="Games.Tala.ClientDevilFishPick">
        /// </param>
        var seat = Games.Tala.TalaState.current.getSeat(m.senderId);
        this._hideSuggest$1();
        this._view$1.set_pickCount(m.numOfRemainCards);
        this._view$1.playerPick(seat).continueWith(Delegate.create(this, function(c) {
            this._bus$1.publish('player.pick', new Games.Tala.PlayerPick(m.senderId));
        }));
    },
    
    _hideSuggestedCard$1: function Games_Tala_TablePart$_hideSuggestedCard$1() {
        if (this._suggestedCard$1 < 0) {
            return;
        }
        var c = Games.Base.Components.CardSuite.instance.get(this._suggestedCard$1);
        c.set_eatAble(false);
        this._suggestedCard$1 = -1;
    },
    
    _onPlayerAttack$1: function Games_Tala_TablePart$_onPlayerAttack$1(d) {
        /// <param name="d" type="Games.Tala.PlayerAttack">
        /// </param>
        var attackerId = d.userId;
        var seat = Games.Tala.TalaState.current.getSeat(attackerId);
        var card = d.card;
        this._lastCard$1 = card;
        this._view$1.playerAttack(seat, card);
        if (Games.Tala.TalaState.current.get_isViewer()) {
            return;
        }
        if (this._canEat$1(card, attackerId)) {
            this._suggestEat$1(card);
        }
        else {
            this._suggestPick$1(attackerId);
        }
    },
    
    _suggestPick$1: function Games_Tala_TablePart$_suggestPick$1(attackerId) {
        /// <param name="attackerId" type="Number" integer="true">
        /// </param>
        var attackerSeat = Games.Tala.TalaState.current.getSeat(attackerId);
        var previousSeat = Games.Tala.TalaState.current.getPreviousSeat(Global.get_user().id);
        this._view$1.suggestPick(attackerSeat === previousSeat);
    },
    
    _suggestEat$1: function Games_Tala_TablePart$_suggestEat$1(card) {
        /// <param name="card" type="Number" integer="true">
        /// </param>
        Debug.writeLine('SuggestEat ' + card);
        this._suggestedCard$1 = card;
        var c = Games.Base.Components.CardSuite.instance.get(card);
        c.set_eatAble(true);
    },
    
    _canEat$1: function Games_Tala_TablePart$_canEat$1(card, attackerId) {
        /// <param name="card" type="Number" integer="true">
        /// </param>
        /// <param name="attackerId" type="Number" integer="true">
        /// </param>
        /// <returns type="Boolean"></returns>
        var attackerSeat = Games.Tala.TalaState.current.getSeat(attackerId);
        var previousSeat = Games.Tala.TalaState.current.getPreviousSeat(Global.get_user().id);
        if (attackerSeat !== previousSeat) {
            return false;
        }
        var cards = Games.Tala.VmgPhoneCardInHand.instance.get_cards();
        var cardInHands = cards.toArray();
        cardInHands.add(card);
        var eatenCards = this._eatCards$1.toArray();
        eatenCards.add(card);
        var phoms = this._phomExtractor$1.extract(cardInHands, eatenCards);
        var canEat = phoms.get_count() > 0;
        return canEat;
    },
    
    _getGuis$1: function Games_Tala_TablePart$_getGuis$1(phoms) {
        /// <param name="phoms" type="ZeroScript.Core.List">
        /// </param>
        /// <returns type="ZeroScript.Core.List"></returns>
        var cards = Games.Tala.VmgPhoneCardInHand.instance.get_cards();
        var remainCards = cards.clone();
        var selected = Games.Tala.VmgPhoneCardInHand.instance.getSelectedCards();
        if (selected.get_count() > 0 && selected.get_item(selected.get_count() - 1) >= 0) {
            remainCards.remove(selected.get_item(selected.get_count() - 1));
        }
        for (var i = 0; i < phoms.get_count(); i++) {
            var phom = phoms.get_item(i);
            for (var j = 0; j < phom.get_item(j); j++) {
                remainCards.remove(phom.get_item(j));
            }
        }
        var phomDaha = new ZeroScript.Core.List();
        for (var i = 0; i < this._allPhoms$1.length; i++) {
            var g = this._allPhoms$1[i];
            if ((g.get_cards()).get_count() > 2) {
                phomDaha.add(new Games.Tala.Phom(g.get_cards(), g.get_id(), g.get_ownerId()));
            }
        }
        return this._phomExtractor$1.gui(remainCards, phomDaha);
    },
    
    active: function Games_Tala_TablePart$active() {
        for (var i = 0; i < 52; i++) {
            var card = Games.Base.Components.CardSuite.instance.get(i);
            card.add_click(Delegate.create(this, this._onCardClick$1));
        }
    },
    
    _onCardClick$1: function Games_Tala_TablePart$_onCardClick$1(sender, x, y) {
        /// <param name="sender" type="ZeroScript.Core.Games.IComponent">
        /// </param>
        /// <param name="x" type="Number" integer="true">
        /// </param>
        /// <param name="y" type="Number" integer="true">
        /// </param>
        var card = sender;
        if (this._checkEatSimple$1(card.get_cardId())) {
            if (this.checkEatComplex(card.get_cardId())) {
                Games.Base.GameRequest.send('Eat.htm');
            }
            else {
                this._view$1.showAnLaoNotify();
            }
        }
    },
    
    checkEatComplex: function Games_Tala_TablePart$checkEatComplex(card) {
        /// <param name="card" type="Number" integer="true">
        /// </param>
        /// <returns type="Boolean"></returns>
        var list = Games.Tala.VmgPhoneCardInHand.instance.get_cards();
        var cardInHands = list.toArray();
        cardInHands.add(card);
        var eatenCards = this._eatCards$1.toArray();
        eatenCards.add(card);
        var phoms = this._phomExtractor$1.extract(cardInHands, eatenCards);
        var canEat = phoms.get_count() > 0;
        return canEat;
    },
    
    _checkEatSimple$1: function Games_Tala_TablePart$_checkEatSimple$1(cardId) {
        /// <param name="cardId" type="Number" integer="true">
        /// </param>
        /// <returns type="Boolean"></returns>
        if (!Games.Tala.TalaState.current.get_isPlaying()) {
            return false;
        }
        if (!Games.Tala.TalaState.current.get_isYourTurn()) {
            return false;
        }
        if (cardId !== this._lastCard$1) {
            return false;
        }
        var cards = Games.Tala.VmgPhoneCardInHand.instance.get_cards();
        if (cards.contains(cardId)) {
            return false;
        }
        return true;
    },
    
    inActive: function Games_Tala_TablePart$inActive() {
    },
    
    init: function Games_Tala_TablePart$init(container) {
        /// <param name="container" type="ZeroScript.Core.Games.IComponentContainer">
        /// </param>
        Games.Tala.TablePart.callBase(this, 'init', [ container ]);
        this.set_width(Games.Tala.VmgPhoneConstant.viewWidth);
        this.set_height(Games.Tala.VmgPhoneConstant.viewHeight);
        var manager = container.get_contentManager();
        var bigSuiteImg = manager.createImageFromUrl(Games.Tala.VmgPhoneConstant.bigCardSuiteUrl);
        var suiteImg = manager.createImageFromUrl(Games.Tala.VmgPhoneConstant.cardSuiteUrl);
        var downImage = manager.createImageFromUrl(Games.Tala.VmgPhoneConstant.facedownUrl);
        var highLight = manager.createImageFromUrl(Games.Tala.TablePart._highLightUrl$1);
        var eat = manager.createImageFromUrl(Games.Tala.TablePart._eatImgUrl$1);
        var marker = manager.createImageFromUrl(Games.Tala.TablePart._markerImgUrl$1);
        this._view$1 = new Games.Tala._tableView();
        this._view$1.set_width(this.get_width());
        this._view$1.set_height(this.get_height());
        this.add(this._view$1);
        this._view$1.add_confirmShow(Delegate.create(this, this._onAutoHaThenAttack$1));
        this._view$1.add_cancelShow(Delegate.create(this, this._onCancelHa$1));
        this._view$1.add_confirmEat(Delegate.create(this, this._onConfirmEat$1));
        var bigSuite = new Games.Tala.VmgPhoneCardSuite(bigSuiteImg, downImage, Games.Tala.VmgPhoneConstant.bigCardWidth, Games.Tala.VmgPhoneConstant.bigCardHeight, highLight, eat, marker);
        bigSuite.set_width(this.get_width());
        bigSuite.set_height(this.get_height());
        bigSuite.set_x(0);
        bigSuite.set_y(0);
        bigSuite.map(Delegate.create(this, this._mapTaLaCards$1));
        this.add(bigSuite);
        var suite = new Games.Base.Components.CardSuite(suiteImg, downImage, Games.Tala.VmgPhoneConstant.cardWidth, Games.Tala.VmgPhoneConstant.cardHeight, highLight, eat, marker);
        suite.set_width(this.get_width());
        suite.set_height(300);
        suite.set_x(0);
        suite.set_y(0);
        suite.map(Delegate.create(this, this._mapTaLaCards$1));
        this.add(suite);
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            this._phoms$1[i] = new Games.Tala.SlotPhom(i);
            var phom = this._phoms$1[i];
            phom.set_x(Games.Tala.VmgPhoneConstant.groupPhomX[i]);
            phom.set_y(Games.Tala.VmgPhoneConstant.groupPhomY[i]);
            phom.set_width(0);
            phom.set_height(0);
            phom.add_phomClick(Delegate.create(this, this._onPhomClick$1));
            this.add(phom);
        }
    },
    
    _onConfirmEat$1: function Games_Tala_TablePart$_onConfirmEat$1() {
        Games.Base.GameRequest.send('Eat.htm');
    },
    
    _onCancelHa$1: function Games_Tala_TablePart$_onCancelHa$1() {
        Games.Base.GameRequest.send('Move.htm', 'cards', [ this._selectedCard$1 ]);
    },
    
    _onAutoHaThenAttack$1: function Games_Tala_TablePart$_onAutoHaThenAttack$1() {
        var attackCard = [ this._selectedCard$1 ];
        var guiString = '';
        for (var i = 0; i < this._guis$1.get_count(); i++) {
            var g = this._guis$1.get_item(i);
            if (g != null) {
                guiString += String.format('{0},{1},{2},', g.get_card(), g.get_phomId(), g.get_phomOwnerId());
            }
        }
        if (isNullOrUndefined(this._phomShow$1) || this._phomShow$1.get_count() === 0) {
            Debug.writeLine('Auto Gui val = ' + guiString);
            for (var i = 0; i < this._guis$1.get_count(); i++) {
                var g = this._guis$1.get_item(i);
                if (g != null) {
                    Games.Base.GameRequest.send('LiveOn.htm', 'cards', g.get_card(), 'phomId', g.get_phomId(), 'targetId', g.get_phomOwnerId());
                }
            }
            Games.Base.GameRequest.send('Move.htm', 'cards', attackCard);
        }
        else {
            Debug.writeLine('Auto Ha');
            var p0 = (isNullOrUndefined(this._phomShow$1.get_item(0))) ? new Array(0) : (this._phomShow$1.get_item(0)).toArray();
            var p1 = (isNullOrUndefined(this._phomShow$1.get_item(1))) ? new Array(1) : (this._phomShow$1.get_item(1)).toArray();
            var p2 = (isNullOrUndefined(this._phomShow$1.get_item(2))) ? new Array(2) : (this._phomShow$1.get_item(2)).toArray();
            Games.Base.GameRequest.send('ShowThenAttack.htm', 'cards', attackCard, 'phom0', p0.toString(), 'phom1', p1.toString(), 'phom2', p2.toString(), 'guis', guiString);
        }
    },
    
    _onPhomClick$1: function Games_Tala_TablePart$_onPhomClick$1(phomId, ownerId) {
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        /// <param name="ownerId" type="Number" integer="true">
        /// </param>
        var cards = Games.Tala.VmgPhoneCardInHand.instance.getSelectedCards();
        Games.Base.GameRequest.send('LiveOn.htm', 'cards', cards.toArray(), 'phomId', phomId, 'targetId', ownerId);
    },
    
    _mapTaLaCards$1: function Games_Tala_TablePart$_mapTaLaCards$1(x, y) {
        /// <param name="x" type="Number" integer="true">
        /// </param>
        /// <param name="y" type="Number" integer="true">
        /// </param>
        /// <returns type="Number" integer="true"></returns>
        return Games.Tala.TablePart._cardType$1[y] * 13 + x;
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala._tableView

Games.Tala._tableView = function Games_Tala__tableView() {
    /// <field name="_pick$1" type="Games.Tala.Picker">
    /// </field>
    /// <field name="_cardCounter$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_groups$1" type="Array" elementType="TalaCardGroup">
    /// </field>
    /// <field name="_templateHaphom$1" type="ZeroScript.Core.Templates.ITemplate">
    /// </field>
    /// <field name="_pickIndicator$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_tableInfo$1" type="Object" domElement="true">
    /// </field>
    /// <field name="__confirmShow$1" type="Callback">
    /// </field>
    /// <field name="__cancelShow$1" type="Callback">
    /// </field>
    /// <field name="__confirmEat$1" type="Callback">
    /// </field>
    this._groups$1 = new Array(Games.Tala.TalaState.maxPlayers);
    Games.Tala._tableView.constructBase(this);
}
Games.Tala._tableView.prototype = {
    _pick$1: null,
    _cardCounter$1: null,
    _templateHaphom$1: null,
    _pickIndicator$1: null,
    _tableInfo$1: null,
    
    loadContent: function Games_Tala__tableView$loadContent() {
        var manager = this.get_container().get_contentManager();
        var imgFacedown = manager.createImageFromUrl(Games.Tala.VmgPhoneConstant.facedownUrl);
        this._cardCounter$1 = document.getElementById('card_counter');
        this._pickIndicator$1 = document.getElementById('pick_indicator');
        this._tableInfo$1 = document.getElementById('table_info');
        this._tableInfo$1.innerHTML = '<p class=\"room\"><i class=\"img\"></i>Ti\u1ec1n c\u01b0\u1ee3c <span>' + Format.currency(Games.Tala.TalaState.current.get_session().baseUnit) + '</span></p>' + '<p class=\"money\"><i class=\"img\"></i>Ph\u00f2ng <span>' + Games.Tala.TalaState.current.get_session().id + '</span></p>';
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            this._groups$1[i] = new Games.Tala.TalaCardGroup(Games.Tala.VmgPhoneConstant.space);
            this._groups$1[i].set_x(Games.Tala.VmgPhoneConstant.cardDaDanhXs[i]);
            this._groups$1[i].set_y(Games.Tala.VmgPhoneConstant.cardDaDanhYs[i]);
            this.add(this._groups$1[i]);
        }
        this._pick$1 = new Games.Tala.Picker(imgFacedown, this._cardCounter$1);
        this._pick$1.set_x(Games.Tala.VmgPhoneConstant.pickX);
        this._pick$1.set_y(Games.Tala.VmgPhoneConstant.pickY);
        this._pick$1.set_width(Games.Tala.VmgPhoneConstant.cardWidth);
        this._pick$1.set_height(Games.Tala.VmgPhoneConstant.cardHeight);
        this.add(this._pick$1);
        EventHelper.attachEvent(this._cardCounter$1, EventHelper.click, Delegate.create(this, this._onDomPickClick$1));
        var d = document.getElementById('template_haphom');
        this._templateHaphom$1 = TemplateEngine.parseTemplate(d.innerHTML);
        var onClose = Delegate.create(this, this.onClose);
        var confirm = Delegate.create(this, this.onConfirm);
        var onBeforeUnload = window.onbeforeunload;
        try {
            window.self.attachEvent('onunload', onClose);
            window.onbeforeunload=Delegate.combine(onBeforeUnload, confirm);
        }
        catch (ex) {
            Debug.writeLine('attach event onbeforeunload error : ' + ex.message);
        }
    },
    
    onClose: function Games_Tala__tableView$onClose() {
        Games.Base.GameRequest.send('LeaveGame.htm');
    },
    
    onConfirm: function Games_Tala__tableView$onConfirm() {
        if (Games.Tala.TalaState.current.get_isViewer()) {
            return;
        }
        if (Games.Tala.TalaState.current.get_session().isPlaying) {
            return 'Tho\u00e1t game \u0111\u1ed3ng ngh\u0129a v\u1edbi b\u1ecf cu\u1ed9c. B\u1ea1n mu\u1ed1n tho\u00e1t?';
        }
        else {
            return 'B\u1ea1n ch\u1eafc ch\u1eafn mu\u1ed1n tho\u00e1t?';
        }
    },
    
    _onDomPickClick$1: function Games_Tala__tableView$_onDomPickClick$1(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        this._sendPick$1();
    },
    
    _sendPick$1: function Games_Tala__tableView$_sendPick$1() {
        Games.Base.GameRequest.send('Pickup.htm');
    },
    
    playerAttack: function Games_Tala__tableView$playerAttack(seat, card) {
        /// <param name="seat" type="Number" integer="true">
        /// </param>
        /// <param name="card" type="Number" integer="true">
        /// </param>
        var c = Games.Base.Components.CardSuite.instance.get(card);
        var fromX = Games.Tala.VmgPhoneConstant.avatarsX[seat];
        var fromY = Games.Tala.VmgPhoneConstant.avatarsY[seat];
        if (seat === 0 && !Games.Tala.TalaState.current.get_isViewer()) {
            var bigCard = Games.Tala.VmgPhoneCardSuite.instance.get(card);
            fromX = bigCard.get_x();
            fromY = bigCard.get_y();
            bigCard.set_visible(false);
        }
        if (this._groups$1[seat] == null) {
            return;
        }
        this._groups$1[seat].attachCard(c, fromX, fromY, false);
    },
    
    get_pickCount: function Games_Tala__tableView$get_pickCount() {
        /// <value type="Number" integer="true"></value>
        return this._pick$1.get_count();
    },
    set_pickCount: function Games_Tala__tableView$set_pickCount(value) {
        /// <value type="Number" integer="true"></value>
        this._pick$1.set_count(value);
        return value;
    },
    
    playerPick: function Games_Tala__tableView$playerPick(seat) {
        /// <param name="seat" type="Number" integer="true">
        /// </param>
        /// <returns type="ZeroScript.Core.Games.IAnimation"></returns>
        this._pick$1.bringToFront();
        var a = this._pick$1.flyTo(Games.Tala.VmgPhoneConstant.avatarsX[seat], Games.Tala.VmgPhoneConstant.avatarsY[seat]);
        a.continueWith(Delegate.create(this, function(c) {
            this._pick$1.hideFly();
        }));
        return a;
    },
    
    resetParams: function Games_Tala__tableView$resetParams() {
        this.suggestPick(false);
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            this._groups$1[i].get_cards().clear();
        }
        for (var i = 0; i < 52; i++) {
            var card = Games.Base.Components.CardSuite.instance.get(i);
            card.set_x(-100);
            card.set_y(-100);
        }
    },
    
    playerEat: function Games_Tala__tableView$playerEat(seat, card) {
        /// <param name="seat" type="Number" integer="true">
        /// </param>
        /// <param name="card" type="Number" integer="true">
        /// </param>
        this._groups$1[seat].get_cards().remove(card);
    },
    
    showSuggestPhomDialog: function Games_Tala__tableView$showSuggestPhomDialog(hasPhom, phoms) {
        /// <param name="hasPhom" type="Boolean">
        /// </param>
        /// <param name="phoms" type="ZeroScript.Core.List">
        /// </param>
        var d = {};
        d['phomCount'] = phoms.get_count();
        d['hasPhom'] = hasPhom;
        var okText = (phoms.get_count() > 0) ? 'H\u1ea1 t\u1ef1 \u0111\u1ed9ng' : 'G\u1eedi';
        var cancelText = (phoms.get_count() > 0) ? ((hasPhom) ? '\u0110\u00e1nh' : 'M\u00f3m') : '\u0110\u00e1nh';
        Games.Base.MessageBox.confirm('Th\u00f4ng b\u00e1o', this._templateHaphom$1.generate(d), Delegate.create(this, function() {
            if (this.__confirmShow$1 != null) {
                this.__confirmShow$1.invoke();
            }
            return true;
        }), Delegate.create(this, function() {
            if (this.__cancelShow$1 != null) {
                this.__cancelShow$1.invoke();
            }
        }), okText, cancelText);
    },
    
    add_confirmShow: function Games_Tala__tableView$add_confirmShow(value) {
        /// <param name="value" type="Function" />
        this.__confirmShow$1 = Delegate.combine(this.__confirmShow$1, value);
    },
    remove_confirmShow: function Games_Tala__tableView$remove_confirmShow(value) {
        /// <param name="value" type="Function" />
        this.__confirmShow$1 = Delegate.remove(this.__confirmShow$1, value);
    },
    
    __confirmShow$1: null,
    
    add_cancelShow: function Games_Tala__tableView$add_cancelShow(value) {
        /// <param name="value" type="Function" />
        this.__cancelShow$1 = Delegate.combine(this.__cancelShow$1, value);
    },
    remove_cancelShow: function Games_Tala__tableView$remove_cancelShow(value) {
        /// <param name="value" type="Function" />
        this.__cancelShow$1 = Delegate.remove(this.__cancelShow$1, value);
    },
    
    __cancelShow$1: null,
    
    rotateCard: function Games_Tala__tableView$rotateCard(fromSeat, toSeat) {
        /// <param name="fromSeat" type="Number" integer="true">
        /// </param>
        /// <param name="toSeat" type="Number" integer="true">
        /// </param>
        var fromCards = this._groups$1[fromSeat].get_cards();
        var card = fromCards.get_item(fromCards.get_count() - 1);
        fromCards.remove(card);
        var c = Games.Base.Components.CardSuite.instance.get(card);
        this._groups$1[toSeat].attachCard(c, c.get_x(), c.get_y(), true);
    },
    
    suggestPick: function Games_Tala__tableView$suggestPick(b) {
        /// <param name="b" type="Boolean">
        /// </param>
        ZeroScript.Core.DomHelper.visible(this._pickIndicator$1, b);
    },
    
    showAnLaoNotify: function Games_Tala__tableView$showAnLaoNotify() {
        Games.Base.MessageBox.confirm(Global.partner.brandName, 'Qu\u00e2n v\u1eeba \u0103n kh\u00f4ng t\u1ea1o th\u00e0nh ph\u1ecfm<br/>B\u1ea1n c\u00f3 mu\u1ed1n ti\u1ebfp t\u1ee5c?', Delegate.create(this, function() {
            if (this.__confirmEat$1 != null) {
                this.__confirmEat$1.invoke();
            }
            return true;
        }), null, '\u0102n li\u1ec1u', 'Kh\u00f4ng \u0103n');
    },
    
    add_confirmEat: function Games_Tala__tableView$add_confirmEat(value) {
        /// <param name="value" type="Function" />
        this.__confirmEat$1 = Delegate.combine(this.__confirmEat$1, value);
    },
    remove_confirmEat: function Games_Tala__tableView$remove_confirmEat(value) {
        /// <param name="value" type="Function" />
        this.__confirmEat$1 = Delegate.remove(this.__confirmEat$1, value);
    },
    
    __confirmEat$1: null
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.TalaAnimation

Games.Tala.TalaAnimation = function Games_Tala_TalaAnimation() {
    /// <field name="_baseImageUrl$1" type="String" static="true">
    /// </field>
    /// <field name="_u$1" type="String" static="true">
    /// </field>
    /// <field name="_chot$1" type="String" static="true">
    /// </field>
    /// <field name="_mom$1" type="String" static="true">
    /// </field>
    /// <field name="_uden$1" type="String" static="true">
    /// </field>
    /// <field name="_dic$1" type="Array" elementType="ImageComponent">
    /// </field>
    this._dic$1 = [];
    Games.Tala.TalaAnimation.constructBase(this);
}
Games.Tala.TalaAnimation.prototype = {
    
    init: function Games_Tala_TalaAnimation$init(container) {
        /// <param name="container" type="ZeroScript.Core.Games.IComponentContainer">
        /// </param>
        Games.Tala.TalaAnimation.callBase(this, 'init', [ container ]);
        var u = new ZeroScript.Core.Games.ImageComponent(Games.Tala.TalaAnimation._u$1);
        var chot = new ZeroScript.Core.Games.ImageComponent(Games.Tala.TalaAnimation._chot$1);
        var mom = new ZeroScript.Core.Games.ImageComponent(Games.Tala.TalaAnimation._mom$1);
        var uden = new ZeroScript.Core.Games.ImageComponent(Games.Tala.TalaAnimation._uden$1);
        this._addElement$1(Games.Tala.DevilFishTransactionReason.anChot, chot);
    },
    
    _addElement$1: function Games_Tala_TalaAnimation$_addElement$1(reason, img) {
        /// <param name="reason" type="Number" integer="true">
        /// </param>
        /// <param name="img" type="ZeroScript.Core.Games.ImageComponent">
        /// </param>
        this._dic$1[reason] = img;
        this._hideElement$1(img);
        this.add(img);
    },
    
    _hideElement$1: function Games_Tala_TalaAnimation$_hideElement$1(img) {
        /// <param name="img" type="ZeroScript.Core.Games.ImageComponent">
        /// </param>
        img.set_x(300);
        img.set_y(600);
    },
    
    initPart: function Games_Tala_TalaAnimation$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        var bus = container.get_bus();
        bus.subcribe('YourCards', Delegate.create(this, this._onGameStart$1));
        bus.subcribe('NewTransaction', Delegate.create(this, this._animate$1));
    },
    
    _onGameStart$1: function Games_Tala_TalaAnimation$_onGameStart$1(m) {
        /// <param name="m" type="Games.Tala.YourCards">
        /// </param>
        for (var i = 0; i < this._dic$1.length; i++) {
            if (this._dic$1[i] == null) {
                continue;
            }
            this._hideElement$1(this._dic$1[i]);
        }
    },
    
    _animate$1: function Games_Tala_TalaAnimation$_animate$1(e) {
        /// <param name="e" type="Games.Tala.NewTransaction">
        /// </param>
        var notifier = this._dic$1[e.reason];
        if (notifier == null) {
            return;
        }
        var x = notifier.get_x();
        notifier.bringToFront();
        var dur = 350;
        var stay = 800;
        notifier.set_x(x);
        notifier.set_y(150);
        notifier.rotate(0, 360, dur).continueWith(Delegate.create(this, function(c) {
            notifier.moveAfterDelay(x, 100, x, -300, dur, stay);
        }));
    },
    
    active: function Games_Tala_TalaAnimation$active() {
    },
    
    inActive: function Games_Tala_TalaAnimation$inActive() {
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.TalaCardGroup

Games.Tala.TalaCardGroup = function Games_Tala_TalaCardGroup(space) {
    /// <param name="space" type="Number" integer="true">
    /// </param>
    /// <field name="_attachDuration$1" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="_cards$1" type="ZeroScript.Core.List">
    /// </field>
    /// <field name="_spaceBetweenCards$1" type="Number" integer="true">
    /// </field>
    this._cards$1 = new ZeroScript.Core.List();
    Games.Tala.TalaCardGroup.constructBase(this);
    this._spaceBetweenCards$1 = space;
}
Games.Tala.TalaCardGroup.prototype = {
    _spaceBetweenCards$1: 0,
    
    get_cards: function Games_Tala_TalaCardGroup$get_cards() {
        /// <value type="ZeroScript.Core.List"></value>
        return this._cards$1;
    },
    
    attachCard: function Games_Tala_TalaCardGroup$attachCard(card, fromX, fromY, isRotate) {
        /// <param name="card" type="Games.Base.Components.Card">
        /// </param>
        /// <param name="fromX" type="Number" integer="true">
        /// </param>
        /// <param name="fromY" type="Number" integer="true">
        /// </param>
        /// <param name="isRotate" type="Boolean">
        /// </param>
        /// <returns type="ZeroScript.Core.Games.IAnimation"></returns>
        this._cards$1.add(card.get_cardId());
        card.bringToFront();
        if (isRotate) {
            card.rotate(240, 360, Games.Tala.TalaCardGroup._attachDuration$1);
        }
        card.set_x(fromX);
        card.set_y(fromY);
        return card.moveTo(this.get_x() + this._spaceBetweenCards$1 * (this._cards$1.get_count() - 1), this.get_y(), Games.Tala.TalaCardGroup._attachDuration$1);
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.VmgPhoneConstant

Games.Tala.VmgPhoneConstant = function Games_Tala_VmgPhoneConstant() {
    /// <field name="cardSuiteUrl" type="String" static="true">
    /// </field>
    /// <field name="bigCardSuiteUrl" type="String" static="true">
    /// </field>
    /// <field name="facedownUrl" type="String" static="true">
    /// </field>
    /// <field name="spaceInHand" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="spaceInPhomW" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="spaceInPhomH" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="space" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="pickX" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="pickY" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="cardInHandX" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="cardInHandY" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="cardWidth" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="cardHeight" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="bigCardWidth" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="bigCardHeight" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="bigSpaceInHand" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="viewWidth" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="viewHeight" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="groupPhomX" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="groupPhomY" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="cardDaDanhXs" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="cardDaDanhYs" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="avatarsX" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="avatarsY" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="handXs" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="handYs" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="cardDaHaX" type="Array" elementType="Array" static="true">
    /// </field>
    /// <field name="cardDaHaY" type="Array" elementType="Array" static="true">
    /// </field>
    /// <field name="handDirects" type="Array" elementType="ExpandDirect" static="true">
    /// </field>
    /// <field name="phomExpands" type="Array" elementType="ExpandDirect" static="true">
    /// </field>
    /// <field name="phomOrders" type="Array" elementType="Array" static="true">
    /// </field>
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.TalaModule

Games.Tala.TalaModule = function Games_Tala_TalaModule() {
    if (this._isFb()) {
        this._loadFb();
    }
    else {
        this._loadNormalModule();
    }
}
Games.Tala.TalaModule.prototype = {
    
    _loadFb: function Games_Tala_TalaModule$_loadFb() {
        Global.get_pageRepository().add('tala', new ZeroScript.Core.Parts.Page([ 'game', 'friends', 'chat', 'tala_chicken', 'timebars_with_level', 'top_level', 'topup', 'top_profile', 'tala_sound', 'tala_bubble', 'tala_state', 'tala_players', 'tala_menu', 'tala_slots', 'bubble_emo', 'tala_result', 'tala_actions', 'tala_news', 'theme', 'tala_result', 'slot_machine', 'slot_machine_sound', 'tala_table', 'tala_animation' ], true));
        var parts = Global.get_partRepository();
        parts.register('tala_table', Delegate.create(this, function() {
            return new Games.Tala.Parts.Fb.FbTablePart();
        }));
        parts.register('tala_state', Delegate.create(this, function() {
            return new Games.Tala.TalaState();
        }));
        parts.register('tala_players', Delegate.create(this, function() {
            return new Games.Tala.Parts.Fb.FbPlayerPart();
        }));
        parts.register('tala_menu', Delegate.create(this, function() {
            return new Games.Tala.vnz.VnzGameMenu();
        }));
        parts.register('tala_slots', Delegate.create(this, function() {
            return new Games.Tala.Parts.Fb.FbSlotPart();
        }));
        parts.register('tala_result', Delegate.create(this, function() {
            return new Games.Tala.vnz.VnzResultPart();
        }));
        parts.register('tala_actions', Delegate.create(this, function() {
            return new Games.Tala.vnz.VnzActionPart();
        }));
        parts.register('tala_sound', Delegate.create(this, function() {
            return new Games.Tala.vnz.VnzTalaSoundPart();
        }));
        parts.register('tala_animation', Delegate.create(this, function() {
            return new Games.Tala.vnz.VnzTalaAnimation();
        }));
        parts.register('tala_news', Delegate.create(this, function() {
            return new Games.Parts.Common.NewsPart();
        }));
        parts.register('tala_chicken', Delegate.create(this, function() {
            return new Games.Parts.Plays.ChickenPart();
        }));
        parts.register('tala_theme', Delegate.create(this, function() {
            return new Games.Parts.Common.ThemePart();
        }));
        parts.register('tala_bubble', Delegate.create(this, function() {
            return new Games.Tala.vnz.VnzBubblePart();
        }));
        Global.get_kernel().init(new Games.Parts.Plays.FacebookChatModule());
    },
    
    _loadMobileVmzModule: function Games_Tala_TalaModule$_loadMobileVmzModule() {
        Global.get_pageRepository().add('tala', new ZeroScript.Core.Parts.Page([ 'game', 'friends', 'chat', 'tala_chicken', 'numberic_timebars', 'top_level', 'topup', 'top_profile', 'tala_sound', 'tala_bubble', 'tala_state', 'tala_players', 'tala_menu', 'tala_slots', 'bubble_emo', 'tala_actions', 'tala_news', 'tala_theme', 'tala_mobi_result', 'tala_table', 'tala_animation' ], true));
        var parts = Global.get_partRepository();
        parts.register('tala_table', Delegate.create(this, function() {
            return new Games.Tala.TablePart();
        }));
        parts.register('tala_state', Delegate.create(this, function() {
            return new Games.Tala.TalaState();
        }));
        parts.register('tala_players', Delegate.create(this, function() {
            return new Games.Tala.PlayerPart();
        }));
        parts.register('tala_menu', Delegate.create(this, function() {
            return new Games.Tala.GameMenu();
        }));
        parts.register('tala_slots', Delegate.create(this, function() {
            return new Games.Tala.SlotPart();
        }));
        parts.register('tala_result', Delegate.create(this, function() {
            return new Games.Tala.ResultPart();
        }));
        parts.register('tala_actions', Delegate.create(this, function() {
            return new Games.Tala.ActionPart();
        }));
        parts.register('tala_sound', Delegate.create(this, function() {
            return new Games.Tala.TalaSoundPart();
        }));
        parts.register('tala_animation', Delegate.create(this, function() {
            return new Games.Tala.TalaAnimation();
        }));
        parts.register('tala_news', Delegate.create(this, function() {
            return new Games.Parts.Common.NewsPart();
        }));
        parts.register('tala_chicken', Delegate.create(this, function() {
            return new Games.Parts.Plays.ChickenPart();
        }));
        parts.register('tala_theme', Delegate.create(this, function() {
            return new Games.Parts.Common.ThemePart();
        }));
        parts.register('tala_bubble', Delegate.create(this, function() {
            return new Games.Tala.BubblePart();
        }));
        parts.register('tala_mobi_result', Delegate.create(this, function() {
            return new Games.Tala.MobieResultPart();
        }));
    },
    
    _loadNormalModule: function Games_Tala_TalaModule$_loadNormalModule() {
        Global.get_pageRepository().add('tala', new ZeroScript.Core.Parts.Page([ 'game', 'friends', 'chat', 'tala_chicken', 'timebars_with_level', 'top_level', 'topup', 'top_profile', 'tala_sound', 'tala_bubble', 'tala_state', 'tala_players', 'tala_menu', 'tala_slots', 'bubble_emo', 'tala_result', 'tala_actions', 'tala_news', 'theme', 'tala_result', 'slot_machine', 'slot_machine_sound', 'tala_table', 'tala_animation' ], true));
        var parts = Global.get_partRepository();
        parts.register('tala_table', Delegate.create(this, function() {
            return new Games.Tala.vnz.VnzTablePart();
        }));
        parts.register('tala_state', Delegate.create(this, function() {
            return new Games.Tala.TalaState();
        }));
        parts.register('tala_players', Delegate.create(this, function() {
            return new Games.Tala.vnz.VnzPlayerPart();
        }));
        parts.register('tala_menu', Delegate.create(this, function() {
            return new Games.Tala.vnz.VnzGameMenu();
        }));
        parts.register('tala_slots', Delegate.create(this, function() {
            return new Games.Tala.vnz.VnzSlotPart();
        }));
        parts.register('tala_result', Delegate.create(this, function() {
            return new Games.Tala.vnz.VnzResultPart();
        }));
        parts.register('tala_actions', Delegate.create(this, function() {
            return new Games.Tala.vnz.VnzActionPart();
        }));
        parts.register('tala_sound', Delegate.create(this, function() {
            return new Games.Tala.vnz.VnzTalaSoundPart();
        }));
        parts.register('tala_animation', Delegate.create(this, function() {
            return new Games.Tala.vnz.VnzTalaAnimation();
        }));
        parts.register('tala_news', Delegate.create(this, function() {
            return new Games.Parts.Common.NewsPart();
        }));
        parts.register('tala_chicken', Delegate.create(this, function() {
            return new Games.Parts.Plays.ChickenPart();
        }));
        parts.register('tala_theme', Delegate.create(this, function() {
            return new Games.Parts.Common.ThemePart();
        }));
        parts.register('tala_bubble', Delegate.create(this, function() {
            return new Games.Tala.vnz.VnzBubblePart();
        }));
    },
    
    _isFb: function Games_Tala_TalaModule$_isFb() {
        /// <returns type="Boolean"></returns>
        return Global.get_ui().toLowerCase() === 'fb';
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.TalaState

Games.Tala.TalaState = function Games_Tala_TalaState() {
    /// <field name="current" type="Games.Tala.TalaState" static="true">
    /// </field>
    /// <field name="maxPlayers" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="host" type="Number" integer="true">
    /// </field>
    /// <field name="currentPlayer" type="Number" integer="true">
    /// </field>
    /// <field name="_yourPlayIndex$1" type="Number" integer="true">
    /// </field>
    /// <field name="_bus$1" type="ZeroScript.Core.IBus">
    /// </field>
    /// <field name="isLastTurn" type="Boolean">
    /// </field>
    /// <field name="_flag$1" type="Boolean">
    /// </field>
    /// <field name="_cardDaDanhCounter$1" type="Array" elementType="Number" elementInteger="true">
    /// </field>
    /// <field name="_pendingJoin$1" type="ZeroScript.Core.List">
    /// </field>
    /// <field name="_lastestSession$1" type="Games.Base.Data.OpenSession">
    /// </field>
    this._cardDaDanhCounter$1 = [ 0, 0, 0, 0 ];
    this._pendingJoin$1 = new ZeroScript.Core.List();
    Games.Tala.TalaState.constructBase(this);
    Games.Tala.TalaState.current = this;
}
Games.Tala.TalaState.prototype = {
    host: 0,
    currentPlayer: 0,
    _yourPlayIndex$1: 0,
    _bus$1: null,
    isLastTurn: false,
    _flag$1: false,
    _lastestSession$1: null,
    
    initPart: function Games_Tala_TalaState$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        this._bus$1 = container.get_bus();
        this._bus$1.subcribe('SessionClosedByServer', Delegate.create(this, this._onSessionClosedByServer$1));
        this._bus$1.subcribe('ChangeHost', Delegate.create(this, this._onChangeHost$1));
        this._bus$1.subcribe('YourCards', Delegate.create(this, this._onGameStart$1));
        this._bus$1.subcribe('GameEnd', Delegate.create(this, this._onGameEnd$1));
        this._bus$1.subcribe('ChangeTurn', Delegate.create(this, this._onChangeTurn$1));
        this._bus$1.subcribe('YourTurn', Delegate.create(this, this._onYourTurn$1));
        this._bus$1.subcribe('PlayerJoinOpenSession', Delegate.create(this, this._onPlayerJoin$1));
        this._bus$1.subcribe('JoinSessionResponse', Delegate.create(this, this._onJoinResponse$1));
        this._bus$1.subcribe('ClientStandUp', Delegate.create(this, this._onStandUp$1));
        this._bus$1.subcribe('ClientLeavePlaySession', Delegate.create(this, this._onPlayerLeavePlaySession$1));
        this._bus$1.subcribe('ClientLeaveOpenSession', Delegate.create(this, this._onPlayerLeaveOpenSession$1));
        this._bus$1.subcribe('ClientDevilFishPick', Delegate.create(this, this._onClientPick$1));
        this._bus$1.subcribe('DevilFishPickResponse', Delegate.create(this, this._onPickResponse$1));
        this._bus$1.subcribe('DevilFishEatResponse', Delegate.create(this, this._onEatResponse$1));
        this._bus$1.subcribe('NewTransaction', Delegate.create(this, this._onTransactionEvent$1));
        this._bus$1.subcribe('player.attack', Delegate.create(this, this._onPlayerAttack$1));
        this._initErrorMsg$1();
    },
    
    _onPlayerAttack$1: function Games_Tala_TalaState$_onPlayerAttack$1(d) {
        /// <param name="d" type="Games.Tala.PlayerAttack">
        /// </param>
        var index = this._getPlayIndex$1(d.userId);
        this._cardDaDanhCounter$1[index]++;
    },
    
    _initErrorMsg$1: function Games_Tala_TalaState$_initErrorMsg$1() {
        var title = Global.partner.brandName;
        Games.Base.MessageBox.addError(GameError.notReady, title, 'Ng\u01b0\u1eddi ch\u01a1i ch\u01b0a s\u1eb5n s\u00e0ng');
        Games.Base.MessageBox.addError(GameError.notOwner, title, 'B\u1ea1n kh\u00f4ng ph\u1ea3i ch\u1ee7 ph\u00f2ng');
        Games.Base.MessageBox.addError(GameError.notEnoughUsers, title, 'Kh\u00f4ng \u0111\u1ee7 ng\u01b0\u1eddi ch\u01a1i');
        Games.Base.MessageBox.addError(GameError.full, title, 'B\u00e0n \u0111ang ch\u01a1i ho\u1eb7c \u0111\u00e3 \u0111\u1ee7 ng\u01b0\u1eddi, kh\u00f4ng v\u00e0o \u0111\u01b0\u1ee3c!');
        Games.Base.MessageBox.addError(GameError.sessionNotFound, title, 'Kh\u00f4ng t\u00ecm th\u1ea5y b\u00e0n \u0111\u1ea5u!');
        Games.Base.MessageBox.addError(GameError.userNotFound, title, 'Kh\u00f4ng t\u00ecm th\u1ea5y ng\u01b0\u1eddi ch\u01a1i!');
        Games.Base.MessageBox.addError(GameError.userNotInSession, title, 'Ng\u01b0\u1eddi ch\u01a1i kh\u00f4ng c\u00f3 trong b\u00e0n \u0111\u1ea5u');
        Games.Base.MessageBox.addError(GameError.invalidData, title, 'D\u1eef li\u1ec7u kh\u00f4ng h\u1ee3p l\u1ec7!');
        Games.Base.MessageBox.addError(GameError.invalidAction, title, 'Thao t\u00e1c kh\u00f4ng ph\u00f9 h\u1ee3p!');
        Games.Base.MessageBox.addError(GameError.invalidTurn, title, 'Ch\u01b0a t\u1edbi l\u01b0\u1ee3t \u0111\u00e1nh!');
        Games.Base.MessageBox.addError(GameError.invalidMove, title, 'Kh\u00f4ng \u0111\u00e1nh \u0111\u01b0\u1ee3c!');
        Games.Base.MessageBox.addError(GameError.leaveQueue, title, 'R\u1eddi kh\u1ecfi gi\u1ea3i \u0111\u1ea5u');
        Games.Base.MessageBox.addError(GameError.canNotStandUpWhilePlaying, title, 'Kh\u00f4ng \u0111\u1ee9ng d\u1eady khi \u0111ang ch\u01a1i');
        Games.Base.MessageBox.addError(GameError.canNotStandUp, title, 'Kh\u00f4ng \u0110\u1ee9ng d\u1eady \u0111\u01b0\u1ee3c. B\u00e0n ch\u1ec9 c\u00f2n m\u1ed9t ng\u01b0\u1eddi!');
        Games.Base.MessageBox.addError(GameError.wrongPassword, title, 'Sai m\u1eadt kh\u1ea9u');
    },
    
    _onTransactionEvent$1: function Games_Tala_TalaState$_onTransactionEvent$1(e) {
        /// <param name="e" type="Games.Tala.NewTransaction">
        /// </param>
        if (e.reason === Games.Tala.DevilFishTransactionReason.anChot || e.reason === Games.Tala.DevilFishTransactionReason.gameEnd) {
            var to = this.toSeat(e.toSlot);
            var from = this.toSeat(e.fromSlot);
            this._bus$1.publish('on.bubble.emoticon', new Games.Base.Data.EmoticonData(to, Games.Base.Data.EmoticonData.happy));
            this._bus$1.publish('on.bubble.emoticon', new Games.Base.Data.EmoticonData(from, Games.Base.Data.EmoticonData.sad));
        }
    },
    
    _onGameEnd$1: function Games_Tala_TalaState$_onGameEnd$1(m) {
        /// <param name="m" type="Games.Base.Messages.GameEnd">
        /// </param>
        this.get_session().isPlaying = false;
        var r = m.result;
        var music = (r.users[0] === this._yourPlayIndex$1) ? 'ext.win' : 'ext.lose';
        this._bus$1.publish(music, null);
        this._bus$1.publish('user.updateMoney', [ Global.get_user() ]);
        this._bus$1.publish('user.updateLevel', [ Global.get_user() ]);
    },
    
    _onGameStart$1: function Games_Tala_TalaState$_onGameStart$1(m) {
        /// <param name="m" type="Games.Tala.YourCards">
        /// </param>
        Games.Parts.Plays.TimeBar.set_timePerTurn(20);
        Games.Parts.Plays.NumbericTimeBar.set_timePerTurn(20);
        if (this.isPending(Global.get_user().id) && !this.get_isPlaying()) {
            Debug.writeLine('xxx start for pending');
            Global.set_gameSession(this._lastestSession$1);
            this._loadSession$1();
        }
        else {
            try {
                for (var i = 0; i < this._pendingJoin$1.get_count(); i++) {
                    var u = this._pendingJoin$1.get_item(i);
                    var playIndex = this._getNextPlayIndex$1(u);
                    this.get_session().users[playIndex] = u;
                    this.get_session().rawUsers[playIndex] = u;
                }
            }
            catch ($e1) {
                Debug.writeLine('exception, _pendingCount: ' + this._pendingJoin$1.get_count());
            }
        }
        this._pendingJoin$1 = new ZeroScript.Core.List();
        this._bus$1.publish('slot.updated', null);
        this.isLastTurn = false;
        this.get_session().isPlaying = true;
        this._cardDaDanhCounter$1 = [ 0, 0, 0, 0 ];
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            var user = this.get_session().users[i];
            if (isNullOrUndefined(user)) {
                continue;
            }
            user.isPlaying = true;
        }
        this._bus$1.publish('ext.start', null);
        if (Global.get_user().id === this.host && !this._flag$1) {
            this._bus$1.publish('startGame', Global.get_gameId());
        }
        this._flag$1 = true;
        this._bus$1.publish('continueGame', Global.get_gameId());
    },
    
    _onEatResponse$1: function Games_Tala_TalaState$_onEatResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishEatResponse">
        /// </param>
        if (m.isLastTurn) {
            this._onLastTurn$1();
        }
        var currentPlayIndex = this._getPlayIndex$1(this.currentPlayer);
        var previousPlayIndex = this._getPreviousIndex$1(currentPlayIndex);
        this._cardDaDanhCounter$1[previousPlayIndex]--;
        if (this._requireRotate$1()) {
            this.rotate();
        }
    },
    
    _getPreviousIndex$1: function Games_Tala_TalaState$_getPreviousIndex$1(playIndex) {
        /// <param name="playIndex" type="Number" integer="true">
        /// </param>
        /// <returns type="Number" integer="true"></returns>
        for (var i = 3; i > 0; i--) {
            var previous = (playIndex + i) % 4;
            if (!isNullOrUndefined(this.get_session().users[previous])) {
                return previous;
            }
        }
        return -1;
    },
    
    rotate: function Games_Tala_TalaState$rotate() {
        var currentPlayIndex = this._getPlayIndex$1(this.currentPlayer);
        var toPlayIndex = this._getPreviousIndex$1(currentPlayIndex);
        var fromPlayIndex = this._getFirstFinishIndex$1();
        if (fromPlayIndex === toPlayIndex) {
            throw ZeroScript.Core.ExceptionFactory.invalidOperation('Loi quay bai, from = to');
        }
        this._cardDaDanhCounter$1[fromPlayIndex]--;
        this._cardDaDanhCounter$1[toPlayIndex]++;
        var fromSeat = this.toSeat(fromPlayIndex);
        var toSeat = this.toSeat(toPlayIndex);
        this._bus$1.publish('require.rotate.card', new Games.Tala.RotateCardData(fromSeat, toSeat));
    },
    
    _requireRotate$1: function Games_Tala_TalaState$_requireRotate$1() {
        /// <returns type="Boolean"></returns>
        var currentPlayIndex = this._getPlayIndex$1(this.currentPlayer);
        var previousPlayIndex = this._getPreviousIndex$1(currentPlayIndex);
        var firstIndex = this._getFirstFinishIndex$1();
        var requireRotate = this._cardDaDanhCounter$1[previousPlayIndex] < this._cardDaDanhCounter$1[firstIndex];
        return requireRotate;
    },
    
    _getFirstFinishIndex$1: function Games_Tala_TalaState$_getFirstFinishIndex$1() {
        /// <returns type="Number" integer="true"></returns>
        var firstFinishIndex;
        var playIndex = this._getPlayIndex$1(this.currentPlayer);
        var n = this._cardDaDanhCounter$1[playIndex];
        for (var i = 0; i < this.get_session().users.length; i++) {
            var u = this.get_session().users[i];
            if (u == null) {
                continue;
            }
            var previousIndex = this._getPreviousIndex$1(playIndex);
            var cardDaDanh = this._cardDaDanhCounter$1[previousIndex];
            if (cardDaDanh >= n) {
                n = cardDaDanh;
                playIndex = previousIndex;
            }
        }
        firstFinishIndex = playIndex;
        return firstFinishIndex;
    },
    
    _onLastTurn$1: function Games_Tala_TalaState$_onLastTurn$1() {
        Games.Parts.Plays.TimeBar.set_timePerTurn(40);
        Games.Parts.Plays.NumbericTimeBar.set_timePerTurn(40);
        this.isLastTurn = true;
        this._bus$1.publish('on.last.turn', null);
    },
    
    _onPickResponse$1: function Games_Tala_TalaState$_onPickResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishPickResponse">
        /// </param>
        if (m.isLastTurn) {
            this._onLastTurn$1();
        }
    },
    
    _onClientPick$1: function Games_Tala_TalaState$_onClientPick$1(m) {
        /// <param name="m" type="Games.Tala.ClientDevilFishPick">
        /// </param>
        if (m.isLastTurn) {
            this._onLastTurn$1();
        }
    },
    
    _onYourTurn$1: function Games_Tala_TalaState$_onYourTurn$1(m) {
        /// <param name="m" type="Games.Base.Messages.YourTurn">
        /// </param>
        this.currentPlayer = Global.get_user().id;
        var seat = this.getSeat(Global.get_user().id);
        this._bus$1.publish('turn.change', seat);
        this._bus$1.publish('ext.yourTurn', null);
    },
    
    _onChangeTurn$1: function Games_Tala_TalaState$_onChangeTurn$1(m) {
        /// <param name="m" type="Games.Base.Messages.ChangeTurn">
        /// </param>
        this.currentPlayer = m.userId;
        var seat = this.getSeat(m.userId);
        this._bus$1.publish('turn.change', seat);
    },
    
    _onChangeHost$1: function Games_Tala_TalaState$_onChangeHost$1(m) {
        /// <param name="m" type="Games.Base.Messages.ChangeHost">
        /// </param>
        this.host = m.newHost;
    },
    
    _onSessionClosedByServer$1: function Games_Tala_TalaState$_onSessionClosedByServer$1(item) {
        /// <param name="item" type="Object">
        /// </param>
        this._bus$1.publish('navigator.backToSession', new Games.Parts.Common.NavigatorParams(Global.get_gameId(), Global.get_channel().id));
    },
    
    _onPlayerLeaveOpenSession$1: function Games_Tala_TalaState$_onPlayerLeaveOpenSession$1(m) {
        /// <param name="m" type="Games.Base.Messages.ClientLeaveOpenSession">
        /// </param>
        this._removeUser$1(m.senderId);
    },
    
    _onPlayerLeavePlaySession$1: function Games_Tala_TalaState$_onPlayerLeavePlaySession$1(m) {
        /// <param name="m" type="Games.Base.Messages.ClientLeavePlaySession">
        /// </param>
        this._removeUser$1(m.senderId);
    },
    
    _removeUser$1: function Games_Tala_TalaState$_removeUser$1(userId) {
        /// <param name="userId" type="Number" integer="true">
        /// </param>
        this._bus$1.publish('player.leave.session', userId);
        var playIndex = this._getPlayIndex$1(userId);
        if (playIndex < 0) {
            return;
        }
        this.get_session().users[playIndex] = null;
        this._bus$1.publish('slot.updated', null);
        this._bus$1.publish('ext.player.leave', null);
    },
    
    _onStandUp$1: function Games_Tala_TalaState$_onStandUp$1(m) {
        /// <param name="m" type="Games.Base.Messages.ClientStandUp">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            return;
        }
        this.host = m.newHost;
        this._removeUser$1(Global.get_user().id);
        this._bus$1.publish('viewer.join', Global.get_user());
        this.set__viewSession$1(null);
    },
    
    _onJoinResponse$1: function Games_Tala_TalaState$_onJoinResponse$1(m) {
        /// <param name="m" type="Games.Base.Messages.JoinSessionRespond">
        /// </param>
        if (GameError.isOkie(m.error)) {
            if (this.get_isPlaying()) {
                this._pendingJoin$1.add(Global.get_user());
                this._lastestSession$1 = m.session;
            }
            else {
                Global.get_user().isPlaying = false;
                Global.set_gameSession(m.session);
                this._loadSession$1();
            }
        }
        else {
            Games.Base.MessageBox.error(m.error);
        }
    },
    
    _onPlayerJoin$1: function Games_Tala_TalaState$_onPlayerJoin$1(m) {
        /// <param name="m" type="Games.Base.Messages.PlayerJoinOpenSession">
        /// </param>
        if (this.get_isPlaying()) {
            this._pendingJoin$1.add(m.user);
        }
        else {
            var playIndex = this._getNextPlayIndex$1(m.user);
            this.get_session().users[playIndex] = m.user;
            this.get_session().rawUsers[playIndex] = m.user;
            this._bus$1.publish('slot.updated', null);
            this._bus$1.publish('ext.player.join', null);
        }
    },
    
    get_session: function Games_Tala_TalaState$get_session() {
        /// <value type="Games.Base.Data.OpenSession"></value>
        return Global.get_gameSession();
    },
    
    get_hasOpenSlot: function Games_Tala_TalaState$get_hasOpenSlot() {
        /// <value type="Boolean"></value>
        for (var i = 0; i < this.get_session().users.length; i++) {
            var u = this.get_session().users[i];
            if (u == null) {
                return true;
            }
        }
        return false;
    },
    
    get_currentUserIsPlayer: function Games_Tala_TalaState$get_currentUserIsPlayer() {
        /// <value type="Boolean"></value>
        return !this.get_isViewer();
    },
    
    get_isYourTurn: function Games_Tala_TalaState$get_isYourTurn() {
        /// <value type="Boolean"></value>
        return this.currentPlayer === Global.get_user().id;
    },
    
    get_isPlaying: function Games_Tala_TalaState$get_isPlaying() {
        /// <value type="Boolean"></value>
        return this.get_session().isPlaying;
    },
    
    active: function Games_Tala_TalaState$active() {
        this._loadSession$1();
        this._flag$1 = false;
    },
    
    _loadSession$1: function Games_Tala_TalaState$_loadSession$1() {
        var s = Global.get_gameSession();
        this.host = this.get_session().owner;
        if (s.rawUsers == null) {
            s.rawUsers = new Array(Games.Tala.TalaState.maxPlayers);
        }
        for (var i = 0; i < s.users.length; i++) {
            s.rawUsers[i] = s.users[i];
            if (isNullOrUndefined(s.users[i])) {
                continue;
            }
        }
        this._yourPlayIndex$1 = this._getPlayIndex$1(Global.get_user().id);
        Games.Parts.Plays.TimeBar.set_timePerTurn(20);
        Games.Parts.Plays.NumbericTimeBar.set_timePerTurn(20);
        if ((this.get_isViewer() || this.get_isWaitter()) && !this.isPending(Global.get_user().id)) {
            if (this.get__viewSession$1() != null) {
                this._replay$1(this.get__viewSession$1().actions);
            }
        }
        this._bus$1.publish('slot.updated', null);
        var themeId = this._getThemeId$1(s.baseUnit);
        this._bus$1.publish('change.theme.request', themeId);
    },
    
    _getThemeId$1: function Games_Tala_TalaState$_getThemeId$1(baseUnit) {
        /// <param name="baseUnit" type="Number" integer="true">
        /// </param>
        /// <returns type="Number" integer="true"></returns>
        var units = (Global.partner.id === 'vmg') ? [ 1000, 2000, 5000, 10000, 20000, 50000 ] : [ 1, 5, 20, 100, 500, 2000, 10000, 50000 ];
        for (var i = 0; i < units.length; i++) {
            if (baseUnit === units[i]) {
                return i;
            }
        }
        return 0;
    },
    
    _replay$1: function Games_Tala_TalaState$_replay$1(actions) {
        /// <param name="actions" type="Array" elementType="GameAction">
        /// </param>
        if (actions.length <= 0) {
            return;
        }
        var gameStart = actions[0].message;
        this._bus$1.publish('YourCards', gameStart);
        for (var i = 1; i < actions.length; i++) {
            var action = actions[i];
            var msg = action.message;
            switch (action.type) {
                case Games.Base.Messages.GameActionTypes.changeTurn:
                    this._onChangeTurn$1(msg);
                    break;
                case Games.Tala.DfAction.move:
                    this._bus$1.publish('ClientDevilFishMove', msg);
                    break;
                case Games.Tala.DfAction.pick:
                    this._bus$1.publish('ClientDevilFishPick', msg);
                    break;
                case Games.Tala.DfAction.eat:
                    this._bus$1.publish('DevilFishEatResponse', msg);
                    break;
                case Games.Tala.DfAction.show:
                    this._bus$1.publish('DevilFishShowResponse', msg);
                    break;
                case Games.Tala.DfAction.liveOn:
                    this._bus$1.publish('DevilFishLiveOnResponse', msg);
                    break;
            }
        }
    },
    
    get__viewSession$1: function Games_Tala_TalaState$get__viewSession$1() {
        /// <value type="Games.Base.Messages.Sessions.ViewSessionResponse"></value>
        return window.viewSession;
    },
    set__viewSession$1: function Games_Tala_TalaState$set__viewSession$1(value) {
        /// <value type="Games.Base.Messages.Sessions.ViewSessionResponse"></value>
        window.viewSession=value;
        return value;
    },
    
    get_isViewer: function Games_Tala_TalaState$get_isViewer() {
        /// <value type="Boolean"></value>
        var users = this.get_session().users;
        for (var i = 0; i < users.length; i++) {
            var u = users[i];
            if (u != null && u.id === Global.get_user().id) {
                return false;
            }
        }
        return true;
    },
    
    get_isWaitter: function Games_Tala_TalaState$get_isWaitter() {
        /// <value type="Boolean"></value>
        var users = this.get_session().users;
        for (var i = 0; i < users.length; i++) {
            var u = users[i];
            if (u != null && u.id === Global.get_user().id && u.isPlaying) {
                return false;
            }
        }
        return true;
    },
    
    getSeat: function Games_Tala_TalaState$getSeat(userId) {
        /// <param name="userId" type="Number" integer="true">
        /// </param>
        /// <returns type="Number" integer="true"></returns>
        var pIndex = this._getPlayIndex$1(userId);
        return this.toSeat(pIndex);
    },
    
    getRawSeat: function Games_Tala_TalaState$getRawSeat(userId) {
        /// <param name="userId" type="Number" integer="true">
        /// </param>
        /// <returns type="Number" integer="true"></returns>
        var pIndex = this._getRawPlayIndex$1(userId);
        return this.toSeat(pIndex);
    },
    
    toSeat: function Games_Tala_TalaState$toSeat(playIndex) {
        /// <param name="playIndex" type="Number" integer="true">
        /// </param>
        /// <returns type="Number" integer="true"></returns>
        if (this._yourPlayIndex$1 < 0) {
            return playIndex;
        }
        if (playIndex < 0 || playIndex > 3) {
            return -1;
        }
        return (Games.Tala.TalaState.maxPlayers - this._yourPlayIndex$1 + playIndex) % Games.Tala.TalaState.maxPlayers;
    },
    
    _getRawPlayIndex$1: function Games_Tala_TalaState$_getRawPlayIndex$1(userId) {
        /// <param name="userId" type="Number" integer="true">
        /// </param>
        /// <returns type="Number" integer="true"></returns>
        var users = this.get_session().rawUsers;
        for (var i = 0; i < users.length; i++) {
            var u = users[i];
            if (u != null && u.id === userId) {
                return i;
            }
        }
        return -1;
    },
    
    _getPlayIndex$1: function Games_Tala_TalaState$_getPlayIndex$1(userId) {
        /// <param name="userId" type="Number" integer="true">
        /// </param>
        /// <returns type="Number" integer="true"></returns>
        var users = this.get_session().rawUsers;
        for (var i = 0; i < users.length; i++) {
            var u = users[i];
            if (u != null && u.id === userId) {
                return i;
            }
        }
        return -1;
    },
    
    _getNextPlayIndex$1: function Games_Tala_TalaState$_getNextPlayIndex$1(user) {
        /// <param name="user" type="Games.Base.Data.User">
        /// </param>
        /// <returns type="Number" integer="true"></returns>
        for (var i = 0; i < this.get_session().users.length; i++) {
            if (this.get_session().users[i] != null) {
                continue;
            }
            this.get_session().users[i] = user;
            return i;
        }
        throw new Error('Session is full, cannot join');
    },
    
    getPickCardsCount: function Games_Tala_TalaState$getPickCardsCount(playerCount) {
        /// <param name="playerCount" type="Number" integer="true">
        /// </param>
        /// <returns type="Number" integer="true"></returns>
        var count = (52 - (4 - playerCount) * (9 + 4) - playerCount * 9 - 1);
        return count;
    },
    
    getPreviousSeat: function Games_Tala_TalaState$getPreviousSeat(playerId) {
        /// <param name="playerId" type="Number" integer="true">
        /// </param>
        /// <returns type="Number" integer="true"></returns>
        var pIndex = this._getPlayIndex$1(playerId);
        for (var i = 3; i > 0; i--) {
            var previousIndex = (pIndex + i) % 4;
            var u = this.get_session().users[previousIndex];
            if (!isNullOrUndefined(u)) {
                return this.getSeat(u.id);
            }
        }
        return -1;
    },
    
    get_tableInfo: function Games_Tala_TalaState$get_tableInfo() {
        /// <value type="String"></value>
        return String.format('C\u01b0\u1ee3c <span class=\'txt_money\'>{0}</span>', Format.currency(this.get_session().baseUnit));
    },
    
    get_pendingJoin: function Games_Tala_TalaState$get_pendingJoin() {
        /// <value type="ZeroScript.Core.List"></value>
        return this._pendingJoin$1;
    },
    
    isPending: function Games_Tala_TalaState$isPending(userId) {
        /// <param name="userId" type="Number" integer="true">
        /// </param>
        /// <returns type="Boolean"></returns>
        for (var i = 0; i < this._pendingJoin$1.get_count(); i++) {
            var u = this._pendingJoin$1.get_item(i);
            if (u.id === userId) {
                return true;
            }
        }
        return false;
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.TalaSoundPart

Games.Tala.TalaSoundPart = function Games_Tala_TalaSoundPart() {
    Games.Tala.TalaSoundPart.constructBase(this);
}
Games.Tala.TalaSoundPart.prototype = {
    
    init: function Games_Tala_TalaSoundPart$init(container) {
        /// <param name="container" type="ZeroScript.Core.Games.IComponentContainer">
        /// </param>
        Games.Tala.TalaSoundPart.callBase(this, 'init', [ container ]);
        this.sound = container.get_soundManager();
        this.sound.add_onLoaded(Delegate.create(this, this._onLoaded$2));
        this.sound.appendTo(document.body);
    },
    
    _onLoaded$2: function Games_Tala_TalaSoundPart$_onLoaded$2() {
        Debug.writeLine('Sound Loaded');
        this.sound.add(Games.Base.Messages.GamePlaySound.join, '_Resources/_Common/mp3/join.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.leave, '_Resources/_Common/mp3/Leave.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.start, '_Resources/_Common/mp3/mario/1up.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.yourTurn, '_Resources/_Common/mp3/Turn.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.error, '_Resources/_Common/mp3/error.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.win, '_Resources/_Common/mp3/mario/Win_Stage.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.lose, '_Resources/_Common/mp3/mario/death.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.alarm, '_Resources/_Common/mp3/car.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.shipBell, '_Resources/_Common/mp3/shipbell.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.throwCard, '_Resources/_Common/mp3/card/throwCard.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.danh, '_Resources/_Common/mp3/mario/Mario_Jump.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.an, '_Resources/_Common/mp3/mario/coin.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.anChot, '_Resources/_Common/mp3/mario/1up.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.gui, '_Resources/_Common/mp3/mario/coin.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.ha, '_Resources/_Common/mp3/mario/coin.mp3');
        var map = {};
        map['ext.player.join'] = Games.Base.Messages.GamePlaySound.join;
        map['ext.player.leave'] = Games.Base.Messages.GamePlaySound.leave;
        map['ext.win'] = Games.Base.Messages.GamePlaySound.win;
        map['ext.lose'] = Games.Base.Messages.GamePlaySound.lose;
        map['ext.halfTime'] = Games.Base.Messages.GamePlaySound.shipBell;
        map['ext.yourTurn'] = Games.Base.Messages.GamePlaySound.yourTurn;
        map['ext.error'] = Games.Base.Messages.GamePlaySound.error;
        map['ext.start'] = Games.Base.Messages.GamePlaySound.start;
        map['ext.throw.card'] = Games.Base.Messages.GamePlaySound.throwCard;
        map['ext.player.danh'] = Games.Base.Messages.GamePlaySound.danh;
        map['ext.player.an'] = Games.Base.Messages.GamePlaySound.an;
        map['ext.player.anchot'] = Games.Base.Messages.GamePlaySound.anChot;
        map['ext.player.gui'] = Games.Base.Messages.GamePlaySound.gui;
        map['ext.player.ha'] = Games.Base.Messages.GamePlaySound.ha;
        this.map(map);
    }
}


Type.createNamespace('Games.Tala.Parts.Fb');

////////////////////////////////////////////////////////////////////////////////
// Games.Tala.Parts.Fb.FbSlotCard

Games.Tala.Parts.Fb.FbSlotCard = function Games_Tala_Parts_Fb_FbSlotCard(slot) {
    /// <param name="slot" type="Number" integer="true">
    /// </param>
    /// <field name="_slot$1" type="Number" integer="true">
    /// </field>
    /// <field name="_handX$1" type="Number" integer="true">
    /// </field>
    /// <field name="_handY$1" type="Number" integer="true">
    /// </field>
    /// <field name="_holder$1" type="Games.Base.Components.FacedownHolder">
    /// </field>
    Games.Tala.Parts.Fb.FbSlotCard.constructBase(this);
    this._slot$1 = slot;
    this._handX$1 = Games.Tala.Parts.Fb.FbConstant.handXs[slot];
    this._handY$1 = Games.Tala.Parts.Fb.FbConstant.handYs[slot];
}
Games.Tala.Parts.Fb.FbSlotCard.prototype = {
    _slot$1: 0,
    _handX$1: 0,
    _handY$1: 0,
    _holder$1: null,
    
    loadContent: function Games_Tala_Parts_Fb_FbSlotCard$loadContent() {
        Games.Tala.Parts.Fb.FbSlotCard.callBase(this, 'loadContent');
        var faceDownH = this.get_container().get_contentManager().createImageFromUrl('_Resources/TaLa/img/facedown.png');
        this._holder$1 = new Games.Base.Components.FacedownHolder(Games.Base.Components.CardSuite.instance.get_faceDownImage(), Games.Base.Components.CardSuite.instance.get_faceDownImage(), 5, 5, 15, 15, 10, Games.Tala.Parts.Fb.FbConstant.directions[this._slot$1]);
        this._holder$1.set_size(0);
        this._holder$1.set_visible(true);
        this._holder$1.set_x(this._handX$1);
        this._holder$1.set_y(this._handY$1);
        this.add(this._holder$1);
    },
    
    puzzle: function Games_Tala_Parts_Fb_FbSlotCard$puzzle() {
        this._holder$1.puzzle(9);
    },
    
    attack: function Games_Tala_Parts_Fb_FbSlotCard$attack(count) {
        /// <param name="count" type="Number" integer="true">
        /// </param>
        this._holder$1.set_size(this._holder$1.get_size() - count);
    },
    
    resetParams: function Games_Tala_Parts_Fb_FbSlotCard$resetParams() {
        this._holder$1.set_size(0);
        this._holder$1.set_x(this._handX$1);
        this._holder$1.set_y(this._handY$1);
    },
    
    showCards: function Games_Tala_Parts_Fb_FbSlotCard$showCards(cards) {
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        this._holder$1.set_size(0);
        this._holder$1.flip(cards);
    },
    
    pick: function Games_Tala_Parts_Fb_FbSlotCard$pick(seat) {
        /// <param name="seat" type="Number" integer="true">
        /// </param>
        this._holder$1.set_size(this._holder$1.get_size() + 1);
    },
    
    eat: function Games_Tala_Parts_Fb_FbSlotCard$eat(card) {
        /// <param name="card" type="Number" integer="true">
        /// </param>
        this._holder$1.set_size(this._holder$1.get_size() + 1);
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.Parts.Fb.FbSlotPhom

Games.Tala.Parts.Fb.FbSlotPhom = function Games_Tala_Parts_Fb_FbSlotPhom(slot) {
    /// <param name="slot" type="Number" integer="true">
    /// </param>
    /// <field name="_phoms$1" type="Array" elementType="PhomGroup">
    /// </field>
    /// <field name="_slot$1" type="Number" integer="true">
    /// </field>
    /// <field name="_handX$1" type="Number" integer="true">
    /// </field>
    /// <field name="_handY$1" type="Number" integer="true">
    /// </field>
    /// <field name="__phomClick$1" type="Games.Tala.PhomClick">
    /// </field>
    this._phoms$1 = new Array(3);
    Games.Tala.Parts.Fb.FbSlotPhom.constructBase(this);
    this._slot$1 = slot;
    this._handX$1 = Games.Tala.Parts.Fb.FbConstant.handXs[slot];
    this._handY$1 = Games.Tala.Parts.Fb.FbConstant.handYs[slot];
}
Games.Tala.Parts.Fb.FbSlotPhom.prototype = {
    _slot$1: 0,
    _handX$1: 0,
    _handY$1: 0,
    
    loadContent: function Games_Tala_Parts_Fb_FbSlotPhom$loadContent() {
        Games.Tala.Parts.Fb.FbSlotPhom.callBase(this, 'loadContent');
        for (var i = 0; i < 3; i++) {
            this._phoms$1[i] = new Games.Tala.Parts.Fb.PhomGroup(Games.Tala.Parts.Fb.FbConstant.expands[this._slot$1]);
            var phom = this._phoms$1[i];
            phom.set_width(Games.Tala.Parts.Fb.FbConstant.cardWidth * 3);
            phom.set_height(Games.Tala.Parts.Fb.FbConstant.cardHeight);
            phom.seatIndex = this._slot$1;
            phom.pos = i;
            phom.set_x(Games.Tala.Parts.Fb.FbConstant.cardDaHaX[this._slot$1][i]);
            phom.set_y(Games.Tala.Parts.Fb.FbConstant.cardDaHaY[this._slot$1][i]);
            phom.add_click(Delegate.create(this, this._onPhomClick$1));
        }
        var order = Games.Tala.Parts.Fb.FbConstant.orders[this._slot$1];
        for (var i = 0; i < order.length; i++) {
            var tmp = order[i];
            this.add(this._phoms$1[tmp]);
        }
    },
    
    add_phomClick: function Games_Tala_Parts_Fb_FbSlotPhom$add_phomClick(value) {
        /// <param name="value" type="Function" />
        this.__phomClick$1 = Delegate.combine(this.__phomClick$1, value);
    },
    remove_phomClick: function Games_Tala_Parts_Fb_FbSlotPhom$remove_phomClick(value) {
        /// <param name="value" type="Function" />
        this.__phomClick$1 = Delegate.remove(this.__phomClick$1, value);
    },
    
    __phomClick$1: null,
    
    _onPhomClick$1: function Games_Tala_Parts_Fb_FbSlotPhom$_onPhomClick$1(sender, x, y) {
        /// <param name="sender" type="ZeroScript.Core.Games.IComponent">
        /// </param>
        /// <param name="x" type="Number" integer="true">
        /// </param>
        /// <param name="y" type="Number" integer="true">
        /// </param>
        var phom = sender;
        if (this.__phomClick$1 != null) {
            this.__phomClick$1.invoke(phom.phomId, phom.ownerId);
        }
    },
    
    _getNextEmptyPhom$1: function Games_Tala_Parts_Fb_FbSlotPhom$_getNextEmptyPhom$1() {
        /// <returns type="Games.Tala.Parts.Fb.PhomGroup"></returns>
        for (var i = 0; i < 3; i++) {
            var p = this._phoms$1[i];
            if (p.eatenCard === -1 && p.get_cards().get_count() === 0) {
                return p;
            }
        }
        return null;
    },
    
    showPhom: function Games_Tala_Parts_Fb_FbSlotPhom$showPhom(cards, phomId, ownerId) {
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        /// <param name="ownerId" type="Number" integer="true">
        /// </param>
        var p = null;
        p = this._getPhomByEatCard$1(cards);
        if (p == null) {
            p = this._getNextEmptyPhom$1();
        }
        p.set_visible(true);
        p.attachCards(new ZeroScript.Core.List(cards), phomId, ownerId, this._handX$1, this._handY$1);
    },
    
    _getPhomByEatCard$1: function Games_Tala_Parts_Fb_FbSlotPhom$_getPhomByEatCard$1(cards) {
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        /// <returns type="Games.Tala.Parts.Fb.PhomGroup"></returns>
        var list = new ZeroScript.Core.List(cards);
        for (var i = 0; i < 3; i++) {
            var p = this._phoms$1[i];
            if (list.contains(p.eatenCard)) {
                return p;
            }
        }
        return null;
    },
    
    gui: function Games_Tala_Parts_Fb_FbSlotPhom$gui(cards, fromSeat, phomId) {
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        /// <param name="fromSeat" type="Number" integer="true">
        /// </param>
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        var p = this._getPhomById$1(phomId);
        var x = Games.Tala.Parts.Fb.FbConstant.handXs[fromSeat];
        var y = Games.Tala.Parts.Fb.FbConstant.handYs[fromSeat];
        if (p == null) {
            return;
        }
        p.attachCards(new ZeroScript.Core.List(cards), phomId, p.ownerId, x, y);
    },
    
    eat: function Games_Tala_Parts_Fb_FbSlotPhom$eat(card) {
        /// <param name="card" type="Number" integer="true">
        /// </param>
        var c = Games.Base.Components.CardSuite.instance.get(card);
        var phom = this._getNextEmptyPhom$1();
        phom.set_visible(true);
        phom.eatenCard = card;
        phom.attachCard(card, -1, -1, c.get_x(), c.get_y());
    },
    
    _getPhomById$1: function Games_Tala_Parts_Fb_FbSlotPhom$_getPhomById$1(phomId) {
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        /// <returns type="Games.Tala.Parts.Fb.PhomGroup"></returns>
        for (var i = 0; i < 3; i++) {
            var p = this._phoms$1[i];
            if (p.phomId === phomId) {
                return p;
            }
        }
        return null;
    },
    
    resetParams: function Games_Tala_Parts_Fb_FbSlotPhom$resetParams() {
        for (var i = 0; i < 3; i++) {
            this._phoms$1[i].set_visible(false);
            this._phoms$1[i].clearCards();
        }
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.Parts.Fb._fbTableView

Games.Tala.Parts.Fb._fbTableView = function Games_Tala_Parts_Fb__fbTableView() {
    /// <field name="_pick$1" type="Games.Tala.Parts.Fb.Picker">
    /// </field>
    /// <field name="_cardCounter$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_groups$1" type="Array" elementType="TalaCardGroup">
    /// </field>
    /// <field name="_templateHaphom$1" type="ZeroScript.Core.Templates.ITemplate">
    /// </field>
    /// <field name="_pickIndicator$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_tableInfo$1" type="Object" domElement="true">
    /// </field>
    /// <field name="__confirmShow$1" type="Callback">
    /// </field>
    /// <field name="__cancelShow$1" type="Callback">
    /// </field>
    /// <field name="__confirmEat$1" type="Callback">
    /// </field>
    this._groups$1 = new Array(Games.Tala.TalaState.maxPlayers);
    Games.Tala.Parts.Fb._fbTableView.constructBase(this);
}
Games.Tala.Parts.Fb._fbTableView.prototype = {
    _pick$1: null,
    _cardCounter$1: null,
    _templateHaphom$1: null,
    _pickIndicator$1: null,
    _tableInfo$1: null,
    
    loadContent: function Games_Tala_Parts_Fb__fbTableView$loadContent() {
        var manager = this.get_container().get_contentManager();
        var cardSuiteImage = manager.createImageFromUrl(Games.Tala.Parts.Fb.FbConstant.cardSuiteUrl);
        var imgBgCounter = manager.createImageFromUrl('_Resources/TaLa/img/card_counter_bg.png');
        var imgFacedown = manager.createImage(cardSuiteImage, 0, 4 * Games.Tala.Parts.Fb.FbConstant.cardHeight, Games.Tala.Parts.Fb.FbConstant.cardWidth, Games.Tala.Parts.Fb.FbConstant.cardHeight);
        this._cardCounter$1 = document.getElementById('card_counter');
        this._pickIndicator$1 = document.getElementById('pick_indicator');
        this._tableInfo$1 = document.getElementById('table_info');
        this._tableInfo$1.innerHTML = Games.Tala.TalaState.current.get_tableInfo();
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            this._groups$1[i] = new Games.Tala.TalaCardGroup(Games.Tala.Parts.Fb.FbConstant.space);
            this._groups$1[i].set_x(Games.Tala.Parts.Fb.FbConstant.cardDaDanhXs[i]);
            this._groups$1[i].set_y(Games.Tala.Parts.Fb.FbConstant.cardDaDanhYs[i]);
            this.add(this._groups$1[i]);
        }
        this._pick$1 = new Games.Tala.Parts.Fb.Picker(imgFacedown, imgBgCounter, this._cardCounter$1);
        this._pick$1.set_x(Games.Tala.Parts.Fb.FbConstant.centerX);
        this._pick$1.set_y(Games.Tala.Parts.Fb.FbConstant.centerY);
        this._pick$1.set_width(Games.Tala.Parts.Fb.FbConstant.cardWidth);
        this._pick$1.set_height(this.get_height());
        this._pick$1.add_click(Delegate.create(this, this._onPickClick$1));
        this.add(this._pick$1);
        EventHelper.attachEvent(this._cardCounter$1, EventHelper.click, Delegate.create(this, this._onDomPickClick$1));
        var d = document.getElementById('template_haphom');
        this._templateHaphom$1 = TemplateEngine.parseTemplate(d.innerHTML);
        var onClose = Delegate.create(this, this.onClose);
        var confirm = Delegate.create(this, this.onConfirm);
        var onBeforeUnload = window.onbeforeunload;
        try {
            window.self.attachEvent('onunload', onClose);
            window.onbeforeunload=Delegate.combine(onBeforeUnload, confirm);
        }
        catch (ex) {
            Debug.writeLine('attach event onbeforeunload error : ' + ex.message);
        }
    },
    
    onClose: function Games_Tala_Parts_Fb__fbTableView$onClose() {
        Games.Base.GameRequest.send('LeaveGame.htm');
    },
    
    onConfirm: function Games_Tala_Parts_Fb__fbTableView$onConfirm() {
        if (Games.Tala.TalaState.current.get_isViewer()) {
            return;
        }
        if (Games.Tala.TalaState.current.get_session().isPlaying) {
            return 'Tho\u00e1t game \u0111\u1ed3ng ngh\u0129a v\u1edbi b\u1ecf cu\u1ed9c. B\u1ea1n mu\u1ed1n tho\u00e1t?';
        }
        else {
            return 'B\u1ea1n ch\u1eafc ch\u1eafn mu\u1ed1n tho\u00e1t?';
        }
    },
    
    _onDomPickClick$1: function Games_Tala_Parts_Fb__fbTableView$_onDomPickClick$1(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        this._sendPick$1();
    },
    
    _onPickClick$1: function Games_Tala_Parts_Fb__fbTableView$_onPickClick$1(sender, x, y) {
        /// <param name="sender" type="ZeroScript.Core.Games.IComponent">
        /// </param>
        /// <param name="x" type="Number" integer="true">
        /// </param>
        /// <param name="y" type="Number" integer="true">
        /// </param>
        this._sendPick$1();
    },
    
    _sendPick$1: function Games_Tala_Parts_Fb__fbTableView$_sendPick$1() {
        Games.Base.GameRequest.send('Pickup.htm');
    },
    
    playerAttack: function Games_Tala_Parts_Fb__fbTableView$playerAttack(seat, card) {
        /// <param name="seat" type="Number" integer="true">
        /// </param>
        /// <param name="card" type="Number" integer="true">
        /// </param>
        var c = Games.Base.Components.CardSuite.instance.get(card);
        var fromX = Games.Tala.Parts.Fb.FbConstant.avatarsX[seat];
        var fromY = Games.Tala.Parts.Fb.FbConstant.avatarsY[seat];
        if (seat === 0 && !Games.Tala.TalaState.current.get_isViewer()) {
            fromX = c.get_x();
            fromY = c.get_y();
        }
        if (this._groups$1[seat] == null) {
            return;
        }
        this._groups$1[seat].attachCard(c, fromX, fromY, false);
    },
    
    get_pickCount: function Games_Tala_Parts_Fb__fbTableView$get_pickCount() {
        /// <value type="Number" integer="true"></value>
        return this._pick$1.get_count();
    },
    set_pickCount: function Games_Tala_Parts_Fb__fbTableView$set_pickCount(value) {
        /// <value type="Number" integer="true"></value>
        this._pick$1.set_count(value);
        return value;
    },
    
    playerPick: function Games_Tala_Parts_Fb__fbTableView$playerPick(seat) {
        /// <param name="seat" type="Number" integer="true">
        /// </param>
        /// <returns type="ZeroScript.Core.Games.IAnimation"></returns>
        this._pick$1.bringToFront();
        var a = this._pick$1.flyTo(Games.Tala.Parts.Fb.FbConstant.avatarsX[seat], Games.Tala.Parts.Fb.FbConstant.avatarsY[seat]);
        a.continueWith(Delegate.create(this, function(c) {
            this._pick$1.hideFly();
        }));
        return a;
    },
    
    resetParams: function Games_Tala_Parts_Fb__fbTableView$resetParams() {
        this.suggestPick(false);
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            this._groups$1[i].get_cards().clear();
        }
        for (var i = 0; i < 52; i++) {
            var card = Games.Base.Components.CardSuite.instance.get(i);
            card.set_x(-100);
            card.set_y(-100);
        }
    },
    
    playerEat: function Games_Tala_Parts_Fb__fbTableView$playerEat(seat, card) {
        /// <param name="seat" type="Number" integer="true">
        /// </param>
        /// <param name="card" type="Number" integer="true">
        /// </param>
        this._groups$1[seat].get_cards().remove(card);
    },
    
    showSuggestPhomDialog: function Games_Tala_Parts_Fb__fbTableView$showSuggestPhomDialog(hasPhom, phoms) {
        /// <param name="hasPhom" type="Boolean">
        /// </param>
        /// <param name="phoms" type="ZeroScript.Core.List">
        /// </param>
        var d = {};
        d['phomCount'] = phoms.get_count();
        d['hasPhom'] = hasPhom;
        var okText = (phoms.get_count() > 0) ? 'H\u1ea1 t\u1ef1 \u0111\u1ed9ng' : 'G\u1eedi';
        var cancelText = (phoms.get_count() > 0) ? ((hasPhom) ? '\u0110\u00e1nh' : 'M\u00f3m') : '\u0110\u00e1nh';
        var dialog = Games.Base.MessageBox.confirm('Th\u00f4ng b\u00e1o', this._templateHaphom$1.generate(d), Delegate.create(this, function() {
            if (this.__confirmShow$1 != null) {
                this.__confirmShow$1.invoke();
            }
            return true;
        }), Delegate.create(this, function() {
            if (this.__cancelShow$1 != null) {
                this.__cancelShow$1.invoke();
            }
        }), okText, cancelText);
        dialog.closeOnBlur = false;
    },
    
    add_confirmShow: function Games_Tala_Parts_Fb__fbTableView$add_confirmShow(value) {
        /// <param name="value" type="Function" />
        this.__confirmShow$1 = Delegate.combine(this.__confirmShow$1, value);
    },
    remove_confirmShow: function Games_Tala_Parts_Fb__fbTableView$remove_confirmShow(value) {
        /// <param name="value" type="Function" />
        this.__confirmShow$1 = Delegate.remove(this.__confirmShow$1, value);
    },
    
    __confirmShow$1: null,
    
    add_cancelShow: function Games_Tala_Parts_Fb__fbTableView$add_cancelShow(value) {
        /// <param name="value" type="Function" />
        this.__cancelShow$1 = Delegate.combine(this.__cancelShow$1, value);
    },
    remove_cancelShow: function Games_Tala_Parts_Fb__fbTableView$remove_cancelShow(value) {
        /// <param name="value" type="Function" />
        this.__cancelShow$1 = Delegate.remove(this.__cancelShow$1, value);
    },
    
    __cancelShow$1: null,
    
    rotateCard: function Games_Tala_Parts_Fb__fbTableView$rotateCard(fromSeat, toSeat) {
        /// <param name="fromSeat" type="Number" integer="true">
        /// </param>
        /// <param name="toSeat" type="Number" integer="true">
        /// </param>
        var fromCards = this._groups$1[fromSeat].get_cards();
        var card = fromCards.get_item(fromCards.get_count() - 1);
        fromCards.remove(card);
        var c = Games.Base.Components.CardSuite.instance.get(card);
        this._groups$1[toSeat].attachCard(c, c.get_x(), c.get_y(), true);
    },
    
    suggestPick: function Games_Tala_Parts_Fb__fbTableView$suggestPick(b) {
        /// <param name="b" type="Boolean">
        /// </param>
        Debug.writeLine('suggest pick ' + b);
        ZeroScript.Core.DomHelper.visible(this._pickIndicator$1, b);
    },
    
    showAnLaoNotify: function Games_Tala_Parts_Fb__fbTableView$showAnLaoNotify() {
        Games.Base.MessageBox.confirm(Global.partner.brandName, 'Qu\u00e2n v\u1eeba \u0103n kh\u00f4ng t\u1ea1o th\u00e0nh ph\u1ecfm<br/>B\u1ea1n c\u00f3 mu\u1ed1n ti\u1ebfp t\u1ee5c?', Delegate.create(this, function() {
            if (this.__confirmEat$1 != null) {
                this.__confirmEat$1.invoke();
            }
            return true;
        }), null, '\u0102n li\u1ec1u', 'Kh\u00f4ng \u0103n');
    },
    
    add_confirmEat: function Games_Tala_Parts_Fb__fbTableView$add_confirmEat(value) {
        /// <param name="value" type="Function" />
        this.__confirmEat$1 = Delegate.combine(this.__confirmEat$1, value);
    },
    remove_confirmEat: function Games_Tala_Parts_Fb__fbTableView$remove_confirmEat(value) {
        /// <param name="value" type="Function" />
        this.__confirmEat$1 = Delegate.remove(this.__confirmEat$1, value);
    },
    
    __confirmEat$1: null
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.Parts.Fb.FbActionPart

Games.Tala.Parts.Fb.FbActionPart = function Games_Tala_Parts_Fb_FbActionPart() {
    /// <field name="_view$1" type="Games.Tala.ActionView">
    /// </field>
    /// <field name="_bus$1" type="ZeroScript.Core.IBus">
    /// </field>
    /// <field name="_attackCard$1" type="Number" integer="true">
    /// </field>
    Games.Tala.Parts.Fb.FbActionPart.constructBase(this);
}
Games.Tala.Parts.Fb.FbActionPart.prototype = {
    _view$1: null,
    _bus$1: null,
    _attackCard$1: 0,
    
    initPart: function Games_Tala_Parts_Fb_FbActionPart$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        this._bus$1 = container.get_bus();
        this._view$1 = new Games.Tala.ActionView();
        this._view$1.add_attack(Delegate.create(this, this._onAttack$1));
        this._view$1.add_sort(Delegate.create(this, this._onSort$1));
        this._view$1.add_u(Delegate.create(this, this._onU$1));
        this._view$1.add_show(Delegate.create(this, this._onShow$1));
        this._bus$1.subcribe('YourCards', Delegate.create(this, this._onGameStart$1));
        this._bus$1.subcribe('GameEnd', Delegate.create(this, this._onGameEnd$1));
        this._bus$1.subcribe('ClientDevilFishMove', Delegate.create(this, this._onClientMove$1));
        this._bus$1.subcribe('DevilFishMoveResponse', Delegate.create(this, this._onMoveResponse$1));
        this._bus$1.subcribe('ChangeTurn', Delegate.create(this, this._onChangeTurn$1));
        this._bus$1.subcribe('YourTurn', Delegate.create(this, this._onYourTurn$1));
        this._bus$1.subcribe('DevilFishPickResponse', Delegate.create(this, this._onPickResponse$1));
        this._bus$1.subcribe('DevilFishEatResponse', Delegate.create(this, this._onEatResponse$1));
        this._bus$1.subcribe('on.last.turn', Delegate.create(this, this._onLastTurn$1));
    },
    
    _onYourTurn$1: function Games_Tala_Parts_Fb_FbActionPart$_onYourTurn$1(item) {
        /// <param name="item" type="Games.Base.Messages.YourTurn">
        /// </param>
        this._view$1.set_state(Games.Tala.ActionState.yourTurn);
    },
    
    _onEatResponse$1: function Games_Tala_Parts_Fb_FbActionPart$_onEatResponse$1(item) {
        /// <param name="item" type="Games.Tala.DevilFishEatResponse">
        /// </param>
        this._view$1.set_state(Games.Tala.ActionState.eat);
    },
    
    _onPickResponse$1: function Games_Tala_Parts_Fb_FbActionPart$_onPickResponse$1(item) {
        /// <param name="item" type="Games.Tala.DevilFishPickResponse">
        /// </param>
        this._view$1.set_state(Games.Tala.ActionState.pick);
    },
    
    _onChangeTurn$1: function Games_Tala_Parts_Fb_FbActionPart$_onChangeTurn$1(m) {
        /// <param name="m" type="Games.Base.Messages.ChangeTurn">
        /// </param>
        if (m.userId !== Global.get_user().id) {
            this._view$1.set_state(Games.Tala.ActionState.someOneTurn);
        }
    },
    
    _onGameStart$1: function Games_Tala_Parts_Fb_FbActionPart$_onGameStart$1(item) {
        /// <param name="item" type="Object">
        /// </param>
        this._view$1.set_state(Games.Tala.ActionState.start);
    },
    
    _onLastTurn$1: function Games_Tala_Parts_Fb_FbActionPart$_onLastTurn$1(d) {
        /// <param name="d" type="Object">
        /// </param>
        this._view$1.set_state(Games.Tala.ActionState.lastTurn);
    },
    
    _onClientMove$1: function Games_Tala_Parts_Fb_FbActionPart$_onClientMove$1(m) {
        /// <param name="m" type="Games.Tala.ClientDevilFishMove">
        /// </param>
        this._publishAttackAction$1(m.senderId, m.card);
    },
    
    _onMoveResponse$1: function Games_Tala_Parts_Fb_FbActionPart$_onMoveResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishMoveResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            Games.Base.MessageBox.notify('Kh\u00f4ng \u0111\u00e1nh \u0111\u01b0\u1ee3c!');
        }
        else {
            var userId = Global.get_user().id;
            Games.Base.Components.CardInHand.instance.attacking = false;
            this._publishAttackAction$1(userId, m.card);
        }
    },
    
    _publishAttackAction$1: function Games_Tala_Parts_Fb_FbActionPart$_publishAttackAction$1(userId, card) {
        /// <param name="userId" type="Number" integer="true">
        /// </param>
        /// <param name="card" type="Number" integer="true">
        /// </param>
        this._bus$1.publish('player.attack', new Games.Tala.PlayerAttack(userId, card));
    },
    
    _onAttack$1: function Games_Tala_Parts_Fb_FbActionPart$_onAttack$1() {
        if (!Games.Tala.TalaState.current.get_isYourTurn()) {
            return;
        }
        var cards = Games.Base.Components.CardInHand.instance.getSelectedCards();
        if (cards.get_count() <= 0) {
            return;
        }
        this._attackCard$1 = cards.get_item(0);
        if (Games.Tala.TalaState.current.isLastTurn) {
            this._bus$1.publish('player.last.attack', new Games.Tala.PlayerAttack(Global.get_user().id, this._attackCard$1));
        }
        else {
            Games.Base.Components.CardInHand.instance.attacking = true;
            Games.Base.GameRequest.send('Move.htm', 'cards', [ this._attackCard$1 ]);
        }
        this._attackCard$1 = -1;
    },
    
    _onShow$1: function Games_Tala_Parts_Fb_FbActionPart$_onShow$1() {
        if (!Games.Tala.TalaState.current.get_isYourTurn()) {
            return;
        }
        var cards = Games.Base.Components.CardInHand.instance.getSelectedCards();
        if (cards.get_count() > 0) {
            var arr = cards.toArray();
            Games.Base.GameRequest.send('ShowPhom.htm', 'cards', arr);
        }
        else {
            this._bus$1.publish('player.show.phom', null);
        }
    },
    
    _onU$1: function Games_Tala_Parts_Fb_FbActionPart$_onU$1() {
        if (!Games.Tala.TalaState.current.get_isYourTurn()) {
            return;
        }
        Games.Base.GameRequest.send('U.htm');
    },
    
    _onSort$1: function Games_Tala_Parts_Fb_FbActionPart$_onSort$1() {
        Games.Base.Components.CardInHand.instance.sort();
    },
    
    _onGameEnd$1: function Games_Tala_Parts_Fb_FbActionPart$_onGameEnd$1(m) {
        /// <param name="m" type="Games.Base.Messages.GameEnd">
        /// </param>
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.Parts.Fb.FbConstant

Games.Tala.Parts.Fb.FbConstant = function Games_Tala_Parts_Fb_FbConstant() {
    /// <field name="cardSuiteUrl" type="String" static="true">
    /// </field>
    /// <field name="space" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="centerX" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="centerY" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="directions" type="Array" elementType="ExpandDirect" static="true">
    /// </field>
    /// <field name="cardWidth" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="cardHeight" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="viewWidth" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="viewHeight" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="groupPhomX" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="groupPhomY" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="slot1PhomX" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="slot1PhomY" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="slot3PhomX" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="slot3PhomY" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="cardDaDanhXs" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="cardDaDanhYs" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="avatarsX" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="avatarsY" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="cardInHandX" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="cardInHandY" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="handXs" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="handYs" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="cardDaHaX" type="Array" elementType="Array" static="true">
    /// </field>
    /// <field name="cardDaHaY" type="Array" elementType="Array" static="true">
    /// </field>
    /// <field name="expands" type="Array" elementType="ExpandDirect" static="true">
    /// </field>
    /// <field name="orders" type="Array" elementType="Array" static="true">
    /// </field>
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.Parts.Fb.FbPlayerPart

Games.Tala.Parts.Fb.FbPlayerPart = function Games_Tala_Parts_Fb_FbPlayerPart() {
    /// <field name="_slots$1" type="Array" elementType="PlayerView">
    /// </field>
    /// <field name="_bus$1" type="ZeroScript.Core.IBus">
    /// </field>
    Games.Tala.Parts.Fb.FbPlayerPart.constructBase(this);
}
Games.Tala.Parts.Fb.FbPlayerPart.prototype = {
    _slots$1: null,
    _bus$1: null,
    
    get_state: function Games_Tala_Parts_Fb_FbPlayerPart$get_state() {
        /// <value type="Games.Tala.TalaState"></value>
        return Games.Tala.TalaState.current;
    },
    
    initPart: function Games_Tala_Parts_Fb_FbPlayerPart$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        this._bus$1 = container.get_bus();
        this._bus$1.subcribe('PlayerJoinOpenSession', Delegate.create(this, this._onPlayerJoin$1));
        this._bus$1.subcribe('JoinSessionResponse', Delegate.create(this, this._onJoinResponse$1));
        this._bus$1.subcribe('YourCards', Delegate.create(this, this._onGameStart$1));
        this._bus$1.subcribe('GameEnd', Delegate.create(this, this._onGameEnd$1));
        this._bus$1.subcribe('DevilFishShowResponse', Delegate.create(this, this._onShowResponse$1));
        this._bus$1.subcribe('slot.updated', Delegate.create(this, this._onSlotUpdated$1));
    },
    
    _onGameStart$1: function Games_Tala_Parts_Fb_FbPlayerPart$_onGameStart$1(item) {
        /// <param name="item" type="Games.Tala.YourCards">
        /// </param>
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            this._slots$1[i].set_showLevel(true);
        }
    },
    
    _onShowResponse$1: function Games_Tala_Parts_Fb_FbPlayerPart$_onShowResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishShowResponse">
        /// </param>
        var seat = Games.Tala.TalaState.current.getSeat(m.senderId);
        if (seat === 1) {
            this._slots$1[seat + 1].set_showLevel(false);
        }
    },
    
    active: function Games_Tala_Parts_Fb_FbPlayerPart$active() {
    },
    
    inActive: function Games_Tala_Parts_Fb_FbPlayerPart$inActive() {
    },
    
    _onGameEnd$1: function Games_Tala_Parts_Fb_FbPlayerPart$_onGameEnd$1(m) {
        /// <param name="m" type="Games.Base.Messages.GameEnd">
        /// </param>
    },
    
    _onJoinResponse$1: function Games_Tala_Parts_Fb_FbPlayerPart$_onJoinResponse$1(m) {
        /// <param name="m" type="Games.Base.Messages.JoinSessionRespond">
        /// </param>
        if (GameError.isOkie(m.error)) {
            this._drawNewPlayer$1();
        }
    },
    
    _onPlayerJoin$1: function Games_Tala_Parts_Fb_FbPlayerPart$_onPlayerJoin$1(m) {
        /// <param name="m" type="Games.Base.Messages.PlayerJoinOpenSession">
        /// </param>
        this._drawNewPlayer$1();
    },
    
    _drawNewPlayer$1: function Games_Tala_Parts_Fb_FbPlayerPart$_drawNewPlayer$1() {
        if (Games.Tala.TalaState.current.get_isPlaying()) {
            var users = Games.Tala.TalaState.current.get_pendingJoin();
            var start = (users.get_count() === 1) ? 0 : 1;
            for (var i = start; i < users.get_count(); i++) {
                var u = users.get_item(i);
                for (var j = 0; j < this._slots$1.length; j++) {
                    if (this._slots$1[j].get_user() == null) {
                        this._slots$1[j].set_user(u);
                        this._slots$1[j].show();
                        this._slots$1[j].showHost(false);
                        break;
                    }
                }
            }
        }
    },
    
    init: function Games_Tala_Parts_Fb_FbPlayerPart$init(container) {
        /// <param name="container" type="ZeroScript.Core.Games.IComponentContainer">
        /// </param>
        Games.Tala.Parts.Fb.FbPlayerPart.callBase(this, 'init', [ container ]);
        this._slots$1 = new Array(Games.Tala.TalaState.maxPlayers);
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            var slot = new Games.Tala.Parts.Fb.PlayerView(i, this._bus$1);
            this._slots$1[i] = slot;
        }
    },
    
    run: function Games_Tala_Parts_Fb_FbPlayerPart$run() {
        this._updateSlots$1();
    },
    
    get_component: function Games_Tala_Parts_Fb_FbPlayerPart$get_component() {
        /// <value type="ZeroScript.Core.Games.IComponent"></value>
        return this;
    },
    
    _onSlotUpdated$1: function Games_Tala_Parts_Fb_FbPlayerPart$_onSlotUpdated$1(text) {
        /// <param name="text" type="String">
        /// </param>
        this._updateSlots$1();
    },
    
    _updateSlots$1: function Games_Tala_Parts_Fb_FbPlayerPart$_updateSlots$1() {
        for (var i = 0; i < this._slots$1.length; i++) {
            this._slots$1[i].set_user(null);
        }
        for (var i = 0; i < this.get_state().get_session().users.length; i++) {
            var u = this.get_state().get_session().users[i];
            if (isNullOrUndefined(u)) {
                continue;
            }
            var seat = this.get_state().getSeat(u.id);
            var playerSlot = this._slots$1[seat];
            playerSlot.set_user(u);
            playerSlot.show();
            playerSlot.showHost(this.get_state().host === u.id);
        }
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.Parts.Fb.FbSlotPart

Games.Tala.Parts.Fb.FbSlotPart = function Games_Tala_Parts_Fb_FbSlotPart() {
    /// <field name="_slots$1" type="Array" elementType="SlotCard">
    /// </field>
    /// <field name="_cardInHand$1" type="Games.Base.Components.CardInHand">
    /// </field>
    /// <field name="_bus$1" type="ZeroScript.Core.IBus">
    /// </field>
    this._slots$1 = new Array(Games.Tala.TalaState.maxPlayers);
    Games.Tala.Parts.Fb.FbSlotPart.constructBase(this);
}
Games.Tala.Parts.Fb.FbSlotPart.prototype = {
    _cardInHand$1: null,
    _bus$1: null,
    
    initPart: function Games_Tala_Parts_Fb_FbSlotPart$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        this._bus$1 = container.get_bus();
        this._bus$1.subcribe('YourCards', Delegate.create(this, this._onGameStart$1));
        this._bus$1.subcribe('GameEnd', Delegate.create(this, this._onGameEnd$1));
        this._bus$1.subcribe('DevilFishPickResponse', Delegate.create(this, this._onPickResponse$1));
        this._bus$1.subcribe('DevilFishEatResponse', Delegate.create(this, this._onEatResponse$1));
        this._bus$1.subcribe('DevilFishShowResponse', Delegate.create(this, this._onShowResponse$1));
        this._bus$1.subcribe('DevilFishLiveOnResponse', Delegate.create(this, this._onGuiResponse$1));
        this._bus$1.subcribe('player.attack', Delegate.create(this, this._onPlayerAttack$1));
        this._bus$1.subcribe('player.pick', Delegate.create(this, this._onPlayerPick$1));
        this._bus$1.subcribe('on.last.turn', Delegate.create(this, this._onLastTurn$1));
        this._bus$1.subcribe('player.leave.session', Delegate.create(this, this._onPlayerLeave$1));
    },
    
    _onPlayerLeave$1: function Games_Tala_Parts_Fb_FbSlotPart$_onPlayerLeave$1(userId) {
        /// <param name="userId" type="Number" integer="true">
        /// </param>
        if (userId === Global.get_user().id) {
            return;
        }
        var seat = Games.Tala.TalaState.current.getSeat(userId);
        this._slots$1[seat].resetParams();
    },
    
    _onLastTurn$1: function Games_Tala_Parts_Fb_FbSlotPart$_onLastTurn$1(d) {
        /// <param name="d" type="Object">
        /// </param>
        this._cardInHand$1.multiSelect = true;
    },
    
    _onGuiResponse$1: function Games_Tala_Parts_Fb_FbSlotPart$_onGuiResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishLiveOnResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            Games.Base.MessageBox.notify('Kh\u00f4ng g\u1eedi \u0111\u01b0\u1ee3c b\u00e0i!');
            return;
        }
        this._bus$1.publish('ext.player.gui', null);
        var seat = Games.Tala.TalaState.current.getSeat(m.senderId);
        if (seat === 0) {
            this._removeCardsInHand$1(m.cards);
        }
        else {
            this._slots$1[seat].attack(m.cards.length);
        }
    },
    
    _onShowResponse$1: function Games_Tala_Parts_Fb_FbSlotPart$_onShowResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishShowResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            Games.Base.MessageBox.notify('Kh\u00f4ng h\u1ea1 \u0111\u01b0\u1ee3c b\u00e0i!');
            return;
        }
        this._bus$1.publish('ext.player.ha', null);
        var seat = Games.Tala.TalaState.current.getSeat(m.senderId);
        if (seat === 0) {
            var cards = m.cards;
            this._removeCardsInHand$1(cards);
        }
        else {
            this._slots$1[seat].attack(m.cards.length);
        }
    },
    
    _removeCardsInHand$1: function Games_Tala_Parts_Fb_FbSlotPart$_removeCardsInHand$1(cards) {
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        var list = this._cardInHand$1.get_cards();
        for (var i = 0; i < cards.length; i++) {
            list.remove(cards[i]);
        }
        this._cardInHand$1.quickResetCards();
    },
    
    _onEatResponse$1: function Games_Tala_Parts_Fb_FbSlotPart$_onEatResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishEatResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            Games.Base.MessageBox.notify('Kh\u00f4ng \u0103n \u0111\u01b0\u1ee3c!');
            return;
        }
        var music = (m.anChot) ? 'ext.player.anchot' : 'ext.player.an';
        this._bus$1.publish(music, null);
        var seat = Games.Tala.TalaState.current.getSeat(m.senderId);
        if (seat === 0 || m.senderId === 0) {
            var card = Games.Base.Components.CardSuite.instance.get(m.card);
            this._addCardToHand$1(card, card.get_x(), card.get_y()).continueWith(Delegate.create(this, function(c) {
                card.set_marked((Games.Tala.TalaState.current.get_isViewer()) ? false : true);
            }));
        }
        else {
            this._slots$1[seat].eat(m.card);
        }
    },
    
    _onPlayerPick$1: function Games_Tala_Parts_Fb_FbSlotPart$_onPlayerPick$1(d) {
        /// <param name="d" type="Games.Tala.PlayerPick">
        /// </param>
        var seat = Games.Tala.TalaState.current.getSeat(d.userId);
        try {
            if (seat < 0) {
                seat = Games.Tala.TalaState.current.getRawSeat(d.userId);
            }
            this._slots$1[seat].pick(seat);
        }
        catch ($e1) {
            Debug.writeLine('exception @SlotPart.OnPlayerPick: seat = ' + seat + ' userId: ' + d.userId);
        }
    },
    
    _onPickResponse$1: function Games_Tala_Parts_Fb_FbSlotPart$_onPickResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishPickResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            return;
        }
        var card = Games.Base.Components.CardSuite.instance.get(m.card);
        this._addCardToHand$1(card, Games.Tala.Parts.Fb.FbConstant.centerX, Games.Tala.Parts.Fb.FbConstant.centerY);
    },
    
    _addCardToHand$1: function Games_Tala_Parts_Fb_FbSlotPart$_addCardToHand$1(card, fromX, fromY) {
        /// <param name="card" type="Games.Base.Components.Card">
        /// </param>
        /// <param name="fromX" type="Number" integer="true">
        /// </param>
        /// <param name="fromY" type="Number" integer="true">
        /// </param>
        /// <returns type="ZeroScript.Core.Games.IAnimation"></returns>
        var cards = this._cardInHand$1.get_cards();
        cards.add(card.get_cardId());
        var x = (cards.get_count() - 1) * Games.Tala.Parts.Fb.FbConstant.space + this._cardInHand$1.handX;
        var y = this._cardInHand$1.handY;
        card.bringToFront();
        return card.move(fromX, fromY, x, y, 500);
    },
    
    active: function Games_Tala_Parts_Fb_FbSlotPart$active() {
        this._cardInHand$1.initCardEvents();
    },
    
    inActive: function Games_Tala_Parts_Fb_FbSlotPart$inActive() {
    },
    
    _onGameEnd$1: function Games_Tala_Parts_Fb_FbSlotPart$_onGameEnd$1(m) {
        /// <param name="m" type="Games.Base.Messages.GameEnd">
        /// </param>
        var r = m.result;
        this._flipCardInHand$1(r.users[0], r.a);
        this._flipCardInHand$1(r.users[1], r.b);
        this._flipCardInHand$1(r.users[2], r.c);
        this._flipCardInHand$1(r.users[3], r.d);
    },
    
    _flipCardInHand$1: function Games_Tala_Parts_Fb_FbSlotPart$_flipCardInHand$1(playIndex, cards) {
        /// <param name="playIndex" type="Number" integer="true">
        /// </param>
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        if (Games.Tala.TalaState.current.get_session().users[playIndex] == null) {
            return;
        }
        var seat = Games.Tala.TalaState.current.toSeat(playIndex);
        if (seat < 0) {
            return;
        }
        if (seat === 0 && !Games.Tala.TalaState.current.get_isViewer()) {
            return;
        }
        this._slots$1[seat].showCards(cards);
    },
    
    _onPlayerAttack$1: function Games_Tala_Parts_Fb_FbSlotPart$_onPlayerAttack$1(d) {
        /// <param name="d" type="Games.Tala.PlayerAttack">
        /// </param>
        var seat = Games.Tala.TalaState.current.getSeat(d.userId);
        if (seat < 0) {
            return;
        }
        this._playerAttack$1(seat, d.card);
        this._bus$1.publish('ext.throw.card', null);
    },
    
    _playerAttack$1: function Games_Tala_Parts_Fb_FbSlotPart$_playerAttack$1(seat, card) {
        /// <param name="seat" type="Number" integer="true">
        /// </param>
        /// <param name="card" type="Number" integer="true">
        /// </param>
        if (seat === 0) {
            var cards = this._cardInHand$1.get_cards();
            cards.remove(card);
            this._cardInHand$1.quickResetCards();
        }
        else {
            this._slots$1[seat].attack(1);
        }
    },
    
    loadContent: function Games_Tala_Parts_Fb_FbSlotPart$loadContent() {
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            this._slots$1[i] = new Games.Tala.Parts.Fb.SlotCard(i);
            var slot = this._slots$1[i];
            slot.set_x(0);
            slot.set_y(0);
            slot.set_width(this.get_width());
            slot.set_height(this.get_height());
            this.add(slot);
        }
        this._cardInHand$1 = new Games.Base.Components.CardInHand(Games.Tala.Parts.Fb.FbConstant.space, Games.Tala.Parts.Fb.FbConstant.cardInHandX, Games.Tala.Parts.Fb.FbConstant.cardInHandY);
        this._cardInHand$1.set_x(Games.Tala.Parts.Fb.FbConstant.cardInHandX);
        this._cardInHand$1.set_y(Games.Tala.Parts.Fb.FbConstant.cardInHandY);
        this._cardInHand$1.set_width(this.get_width());
        this._cardInHand$1.set_height(this.get_height());
        this.add(this._cardInHand$1);
        Games.Tala.Parts.Fb.FbSlotPart.callBase(this, 'loadContent');
    },
    
    _onGameStart$1: function Games_Tala_Parts_Fb_FbSlotPart$_onGameStart$1(m) {
        /// <param name="m" type="Games.Tala.YourCards">
        /// </param>
        this._resetParams$1();
        this._chiaBai$1(m);
    },
    
    _resetParams$1: function Games_Tala_Parts_Fb_FbSlotPart$_resetParams$1() {
        this._cardInHand$1.handX = Games.Tala.Parts.Fb.FbConstant.cardInHandX;
        this._cardInHand$1.multiSelect = false;
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            this._slots$1[i].resetParams();
        }
    },
    
    _chiaBai$1: function Games_Tala_Parts_Fb_FbSlotPart$_chiaBai$1(m) {
        /// <param name="m" type="Games.Tala.YourCards">
        /// </param>
        Games.Base.Components.CardSuite.instance.resetAllCards();
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            var user = Games.Tala.TalaState.current.get_session().users[i];
            if (isNullOrUndefined(user)) {
                continue;
            }
            if (Games.Tala.TalaState.current.isPending(user.id)) {
                continue;
            }
            var seat = Games.Tala.TalaState.current.getSeat(user.id);
            if (seat === 0 && Games.Tala.TalaState.current.get_currentUserIsPlayer()) {
                this._cardInHand$1.set_cards(new ZeroScript.Core.List(m.cards));
                this._cardInHand$1.chiaBai();
            }
            else {
                this._slots$1[seat].puzzle();
            }
        }
    },
    
    get_component: function Games_Tala_Parts_Fb_FbSlotPart$get_component() {
        /// <value type="ZeroScript.Core.Games.IComponent"></value>
        return this;
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.Parts.Fb.FbTablePart

Games.Tala.Parts.Fb.FbTablePart = function Games_Tala_Parts_Fb_FbTablePart() {
    /// <field name="_baseImageUrl$1" type="String" static="true">
    /// </field>
    /// <field name="_cardSuiteUrl$1" type="String" static="true">
    /// </field>
    /// <field name="_highLightUrl$1" type="String" static="true">
    /// </field>
    /// <field name="_eatImgUrl$1" type="String" static="true">
    /// </field>
    /// <field name="_markerImgUrl$1" type="String" static="true">
    /// </field>
    /// <field name="_cardType$1" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="_eatCards$1" type="ZeroScript.Core.List">
    /// </field>
    /// <field name="_view$1" type="Games.Tala.Parts.Fb._fbTableView">
    /// </field>
    /// <field name="_phoms$1" type="Array" elementType="SlotPhom">
    /// </field>
    /// <field name="_allPhoms$1" type="Array" elementType="Phom">
    /// </field>
    /// <field name="_bus$1" type="ZeroScript.Core.IBus">
    /// </field>
    /// <field name="_phomExtractor$1" type="PhomExtractor">
    /// </field>
    /// <field name="_suggestedCard$1" type="Number" integer="true">
    /// </field>
    /// <field name="_selectedCard$1" type="Number" integer="true">
    /// </field>
    /// <field name="_phomShow$1" type="ZeroScript.Core.List">
    /// </field>
    /// <field name="_guis$1" type="ZeroScript.Core.List">
    /// </field>
    /// <field name="_rotateData$1" type="Games.Tala.RotateCardData">
    /// </field>
    /// <field name="_lastCard$1" type="Number" integer="true">
    /// </field>
    /// <field name="_hasPhom$1" type="Boolean">
    /// </field>
    this._phoms$1 = new Array(Games.Tala.TalaState.maxPlayers);
    this._allPhoms$1 = new Array(12);
    Games.Tala.Parts.Fb.FbTablePart.constructBase(this);
    this._phomExtractor$1 = new PhomExtractor();
}
Games.Tala.Parts.Fb.FbTablePart.prototype = {
    _eatCards$1: null,
    _view$1: null,
    _bus$1: null,
    _phomExtractor$1: null,
    _suggestedCard$1: 0,
    _selectedCard$1: 0,
    _phomShow$1: null,
    _guis$1: null,
    _rotateData$1: null,
    _lastCard$1: 0,
    _hasPhom$1: false,
    
    initPart: function Games_Tala_Parts_Fb_FbTablePart$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        this._bus$1 = container.get_bus();
        this._bus$1.subcribe('ClientDevilFishPick', Delegate.create(this, this._onClientPick$1));
        this._bus$1.subcribe('DevilFishPickResponse', Delegate.create(this, this._onPickResponse$1));
        this._bus$1.subcribe('YourCards', Delegate.create(this, this._onGameStart$1));
        this._bus$1.subcribe('GameEnd', Delegate.create(this, this._onGameEnd$1));
        this._bus$1.subcribe('DevilFishEatResponse', Delegate.create(this, this._onEatResponse$1));
        this._bus$1.subcribe('DevilFishShowResponse', Delegate.create(this, this._onShowResponse$1));
        this._bus$1.subcribe('DevilFishUResponse', Delegate.create(this, this._onUResponse$1));
        this._bus$1.subcribe('DevilFishLiveOnResponse', Delegate.create(this, this._onGuiResponse$1));
        this._bus$1.subcribe('player.attack', Delegate.create(this, this._onPlayerAttack$1));
        this._bus$1.subcribe('player.last.attack', Delegate.create(this, this._onLastAttack$1));
        this._bus$1.subcribe('player.show.phom', Delegate.create(this, this._onShowPhomOnly$1));
        this._bus$1.subcribe('require.rotate.card', Delegate.create(this, this._onRotate$1));
    },
    
    _onRotate$1: function Games_Tala_Parts_Fb_FbTablePart$_onRotate$1(d) {
        /// <param name="d" type="Games.Tala.RotateCardData">
        /// </param>
        this._rotateData$1 = d;
    },
    
    _onShowPhomOnly$1: function Games_Tala_Parts_Fb_FbTablePart$_onShowPhomOnly$1(d) {
        /// <param name="d" type="Object">
        /// </param>
        this._phomShow$1 = this._getPhoms$1();
        this._guis$1 = this._getGuis$1(this._phomShow$1);
        for (var i = 0; i < this._phomShow$1.get_count(); i++) {
            var p = this._phomShow$1.get_item(i);
            var arr = p.toArray();
            Games.Base.GameRequest.send('ShowPhom.htm', 'cards', arr);
        }
        for (var i = 0; i < this._guis$1.get_count(); i++) {
            var g = this._guis$1.get_item(i);
            if (isNullOrUndefined(g)) {
                continue;
            }
            Games.Base.GameRequest.send('LiveOn.htm', 'cards', [ g.get_card() ], 'phomId', g.get_phomId(), 'targetId', g.get_phomOwnerId());
        }
    },
    
    _onLastAttack$1: function Games_Tala_Parts_Fb_FbTablePart$_onLastAttack$1(d) {
        /// <param name="d" type="Games.Tala.PlayerAttack">
        /// </param>
        this._selectedCard$1 = d.card;
        this._phomShow$1 = this._getPhoms$1();
        this._guis$1 = this._getGuis$1(this._phomShow$1);
        var hasPhom = this._phomShow$1.get_count() > 0;
        var hasGui = this._hasPhom$1 && this._guiAble$1(this._guis$1);
        if (hasPhom || hasGui) {
            this._view$1.showSuggestPhomDialog(hasPhom, this._phomShow$1);
        }
        else {
            Games.Base.GameRequest.send('Move.htm', 'cards', [ this._selectedCard$1 ]);
        }
    },
    
    _guiAble$1: function Games_Tala_Parts_Fb_FbTablePart$_guiAble$1(guis) {
        /// <param name="guis" type="ZeroScript.Core.List">
        /// </param>
        /// <returns type="Boolean"></returns>
        for (var i = 0; i < guis.get_count(); i++) {
            var g = guis.get_item(i);
            if (g == null) {
                continue;
            }
            return true;
        }
        return false;
    },
    
    _getPhoms$1: function Games_Tala_Parts_Fb_FbTablePart$_getPhoms$1() {
        /// <returns type="ZeroScript.Core.List"></returns>
        var cards = Games.Base.Components.CardInHand.instance.get_cards();
        var remainCards = new ZeroScript.Core.List(cards.toArray());
        if (this._selectedCard$1 >= 0) {
            remainCards.remove(this._selectedCard$1);
        }
        var phoms = this._phomExtractor$1.extract(remainCards.toArray(), this._eatCards$1.toArray());
        return phoms;
    },
    
    _onGameEnd$1: function Games_Tala_Parts_Fb_FbTablePart$_onGameEnd$1(m) {
        /// <param name="m" type="Games.Base.Messages.GameEnd">
        /// </param>
        this._hideSuggest$1();
        var r = m.result;
        if (this._hasPlayerU$1(r)) {
            var seat = Games.Tala.TalaState.current.getSeat(Games.Tala.TalaState.current.currentPlayer);
            for (var i = 0; i < r.uPhoms.length; i++) {
                var cards = r.uPhoms[i];
                if (seat === 1) {
                    this._phoms$1[seat].set_x(Games.Tala.Parts.Fb.FbConstant.groupPhomX[seat]);
                    this._phoms$1[seat].set_y(Games.Tala.Parts.Fb.FbConstant.groupPhomY[seat] + 20);
                }
                this._phoms$1[seat].showPhom(cards, -1, -1);
            }
        }
    },
    
    _hasPlayerU$1: function Games_Tala_Parts_Fb_FbTablePart$_hasPlayerU$1(r) {
        /// <param name="r" type="Games.Tala.DevilFishGameResult">
        /// </param>
        /// <returns type="Boolean"></returns>
        for (var rank = 0; rank < r.finalUserScores.length; rank++) {
            var finalUserScore = r.finalUserScores[rank];
            if (finalUserScore.indexOf('U') >= 0) {
                return true;
            }
        }
        return false;
    },
    
    _onGuiResponse$1: function Games_Tala_Parts_Fb_FbTablePart$_onGuiResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishLiveOnResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            return;
        }
        var fromSeat = Games.Tala.TalaState.current.getSeat(Games.Tala.TalaState.current.currentPlayer);
        var toSeat = Games.Tala.TalaState.current.getSeat(m.targerId);
        this._phoms$1[toSeat].gui(m.cards, fromSeat, m.phomId);
    },
    
    _onUResponse$1: function Games_Tala_Parts_Fb_FbTablePart$_onUResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishUResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            Games.Base.MessageBox.notify('Ch\u01b0a \u00f9 \u0111\u01b0\u1ee3c!');
        }
    },
    
    _onShowResponse$1: function Games_Tala_Parts_Fb_FbTablePart$_onShowResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishShowResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            return;
        }
        var seat = Games.Tala.TalaState.current.getSeat(m.ownerId);
        if (seat === 0) {
            this._hasPhom$1 = true;
            this._phoms$1[seat].set_x(Games.Tala.Parts.Fb.FbConstant.groupPhomX[seat] - m.cards.length * Games.Tala.Parts.Fb.FbConstant.space);
            for (var i = 0; i < m.cards.length; i++) {
                this._eatCards$1.remove(m.cards[i]);
            }
        }
        if (seat === 1 || seat === 3) {
            this._phoms$1[seat].set_x(Games.Tala.Parts.Fb.FbConstant.groupPhomX[seat]);
            this._phoms$1[seat].set_y(Games.Tala.Parts.Fb.FbConstant.groupPhomY[seat]);
        }
        this._phoms$1[seat].showPhom(m.cards, m.phomId, m.ownerId);
        var phomSlot = this._getEmptyPhom$1();
        this._allPhoms$1[phomSlot] = new Games.Tala.Phom(new ZeroScript.Core.List(m.cards), m.phomId, m.ownerId);
    },
    
    _getEmptyPhom$1: function Games_Tala_Parts_Fb_FbTablePart$_getEmptyPhom$1() {
        /// <returns type="Number" integer="true"></returns>
        for (var slot = 0; slot < this._allPhoms$1.length; slot++) {
            if (this._allPhoms$1[slot].get_ownerId() === -1) {
                return slot;
            }
        }
        return -1;
    },
    
    _onEatResponse$1: function Games_Tala_Parts_Fb_FbTablePart$_onEatResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishEatResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            return;
        }
        this._hideSuggest$1();
        var id = (m.senderId === 0) ? Games.Tala.TalaState.current.currentPlayer : m.senderId;
        var currentSeat = Games.Tala.TalaState.current.getSeat(id);
        var previousSeat = Games.Tala.TalaState.current.getPreviousSeat(id);
        if (currentSeat === 0 || m.senderId === 0) {
            this._eatCards$1.add(m.card);
        }
        else {
            this._phoms$1[currentSeat].eat(m.card);
        }
        this._view$1.playerEat(previousSeat, m.card);
        if (this._rotateData$1 != null) {
            Debug.writeLine('Rotate from: ' + this._rotateData$1.fromSeat + ' to: ' + this._rotateData$1.toSeat);
            this._view$1.rotateCard(this._rotateData$1.fromSeat, this._rotateData$1.toSeat);
            this._rotateData$1 = null;
        }
    },
    
    _onGameStart$1: function Games_Tala_Parts_Fb_FbTablePart$_onGameStart$1(item) {
        /// <param name="item" type="Games.Tala.YourCards">
        /// </param>
        this._resetParams$1();
        var playerCount = 0;
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            var user = Games.Tala.TalaState.current.get_session().users[i];
            if (isNullOrUndefined(user)) {
                continue;
            }
            playerCount++;
        }
        var pickCount = Games.Tala.TalaState.current.getPickCardsCount(playerCount);
        this._view$1.set_pickCount(pickCount);
    },
    
    _resetParams$1: function Games_Tala_Parts_Fb_FbTablePart$_resetParams$1() {
        this._hasPhom$1 = false;
        this._lastCard$1 = -1;
        this._rotateData$1 = null;
        this._phomShow$1 = new ZeroScript.Core.List();
        this._guis$1 = new ZeroScript.Core.List();
        this._suggestedCard$1 = -1;
        this._selectedCard$1 = -1;
        this._eatCards$1 = new ZeroScript.Core.List();
        this._view$1.resetParams();
        for (var i = 0; i < this._phoms$1.length; i++) {
            this._phoms$1[i].resetParams();
            this._phoms$1[i].set_x(Games.Tala.Parts.Fb.FbConstant.groupPhomX[i]);
            if (i === 1) {
                this._phoms$1[i].set_x(Games.Tala.Parts.Fb.FbConstant.slot1PhomX);
                this._phoms$1[i].set_y(Games.Tala.Parts.Fb.FbConstant.slot1PhomY);
            }
            if (i === 3) {
                this._phoms$1[i].set_x(Games.Tala.Parts.Fb.FbConstant.slot3PhomX);
                this._phoms$1[i].set_y(Games.Tala.Parts.Fb.FbConstant.slot3PhomY);
            }
        }
        for (var i = 0; i < this._allPhoms$1.length; i++) {
            this._allPhoms$1[i] = new Games.Tala.Phom(new ZeroScript.Core.List(), -1, -1);
        }
    },
    
    _onPickResponse$1: function Games_Tala_Parts_Fb_FbTablePart$_onPickResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishPickResponse">
        /// </param>
        this._view$1.set_pickCount(m.numOfRemainCards);
        this._hideSuggest$1();
    },
    
    _hideSuggest$1: function Games_Tala_Parts_Fb_FbTablePart$_hideSuggest$1() {
        this._hideSuggestedCard$1();
        this._view$1.suggestPick(false);
    },
    
    _onClientPick$1: function Games_Tala_Parts_Fb_FbTablePart$_onClientPick$1(m) {
        /// <param name="m" type="Games.Tala.ClientDevilFishPick">
        /// </param>
        var seat = Games.Tala.TalaState.current.getSeat(m.senderId);
        this._hideSuggest$1();
        this._view$1.set_pickCount(m.numOfRemainCards);
        this._view$1.playerPick(seat).continueWith(Delegate.create(this, function(c) {
            this._bus$1.publish('player.pick', new Games.Tala.PlayerPick(m.senderId));
        }));
    },
    
    _hideSuggestedCard$1: function Games_Tala_Parts_Fb_FbTablePart$_hideSuggestedCard$1() {
        if (this._suggestedCard$1 < 0) {
            return;
        }
        var c = Games.Base.Components.CardSuite.instance.get(this._suggestedCard$1);
        c.set_eatAble(false);
        this._suggestedCard$1 = -1;
    },
    
    _onPlayerAttack$1: function Games_Tala_Parts_Fb_FbTablePart$_onPlayerAttack$1(d) {
        /// <param name="d" type="Games.Tala.PlayerAttack">
        /// </param>
        var attackerId = d.userId;
        var seat = Games.Tala.TalaState.current.getSeat(attackerId);
        var card = d.card;
        this._lastCard$1 = card;
        this._view$1.playerAttack(seat, card);
        if (Games.Tala.TalaState.current.get_isViewer()) {
            return;
        }
        if (this._canEat$1(card, attackerId)) {
            this._suggestEat$1(card);
        }
        else {
            this._suggestPick$1(attackerId);
        }
    },
    
    _suggestPick$1: function Games_Tala_Parts_Fb_FbTablePart$_suggestPick$1(attackerId) {
        /// <param name="attackerId" type="Number" integer="true">
        /// </param>
        var attackerSeat = Games.Tala.TalaState.current.getSeat(attackerId);
        var previousSeat = Games.Tala.TalaState.current.getPreviousSeat(Global.get_user().id);
        this._view$1.suggestPick(attackerSeat === previousSeat);
    },
    
    _suggestEat$1: function Games_Tala_Parts_Fb_FbTablePart$_suggestEat$1(card) {
        /// <param name="card" type="Number" integer="true">
        /// </param>
        this._suggestedCard$1 = card;
        var c = Games.Base.Components.CardSuite.instance.get(card);
        c.set_eatAble(true);
    },
    
    _canEat$1: function Games_Tala_Parts_Fb_FbTablePart$_canEat$1(card, attackerId) {
        /// <param name="card" type="Number" integer="true">
        /// </param>
        /// <param name="attackerId" type="Number" integer="true">
        /// </param>
        /// <returns type="Boolean"></returns>
        var attackerSeat = Games.Tala.TalaState.current.getSeat(attackerId);
        var previousSeat = Games.Tala.TalaState.current.getPreviousSeat(Global.get_user().id);
        if (attackerSeat !== previousSeat) {
            return false;
        }
        var cards = Games.Base.Components.CardInHand.instance.get_cards();
        var cardInHands = cards.toArray();
        cardInHands.add(card);
        var eatenCards = this._eatCards$1.toArray();
        eatenCards.add(card);
        var phoms = this._phomExtractor$1.extract(cardInHands, eatenCards);
        var canEat = phoms.get_count() > 0;
        return canEat;
    },
    
    _getGuis$1: function Games_Tala_Parts_Fb_FbTablePart$_getGuis$1(phoms) {
        /// <param name="phoms" type="ZeroScript.Core.List">
        /// </param>
        /// <returns type="ZeroScript.Core.List"></returns>
        var cards = Games.Base.Components.CardInHand.instance.get_cards();
        var remainCards = cards.clone();
        var selected = Games.Base.Components.CardInHand.instance.getSelectedCards();
        if (selected.get_count() > 0 && selected.get_item(selected.get_count() - 1) >= 0) {
            remainCards.remove(selected.get_item(selected.get_count() - 1));
        }
        for (var i = 0; i < phoms.get_count(); i++) {
            var phom = phoms.get_item(i);
            for (var j = 0; j < phom.get_item(j); j++) {
                remainCards.remove(phom.get_item(j));
            }
        }
        var phomDaha = new ZeroScript.Core.List();
        for (var i = 0; i < this._allPhoms$1.length; i++) {
            var g = this._allPhoms$1[i];
            if ((g.get_cards()).get_count() > 2) {
                phomDaha.add(new Games.Tala.Phom(g.get_cards(), g.get_id(), g.get_ownerId()));
            }
        }
        return this._phomExtractor$1.gui(remainCards, phomDaha);
    },
    
    active: function Games_Tala_Parts_Fb_FbTablePart$active() {
        for (var i = 0; i < 52; i++) {
            var card = Games.Base.Components.CardSuite.instance.get(i);
            card.add_click(Delegate.create(this, this._onCardClick$1));
        }
    },
    
    _onCardClick$1: function Games_Tala_Parts_Fb_FbTablePart$_onCardClick$1(sender, x, y) {
        /// <param name="sender" type="ZeroScript.Core.Games.IComponent">
        /// </param>
        /// <param name="x" type="Number" integer="true">
        /// </param>
        /// <param name="y" type="Number" integer="true">
        /// </param>
        var card = sender;
        if (this._checkEatSimple$1(card.get_cardId())) {
            if (this.checkEatComplex(card.get_cardId())) {
                Games.Base.GameRequest.send('Eat.htm');
            }
            else {
                this._view$1.showAnLaoNotify();
            }
        }
    },
    
    checkEatComplex: function Games_Tala_Parts_Fb_FbTablePart$checkEatComplex(card) {
        /// <param name="card" type="Number" integer="true">
        /// </param>
        /// <returns type="Boolean"></returns>
        var list = Games.Base.Components.CardInHand.instance.get_cards();
        var cardInHands = list.toArray();
        cardInHands.add(card);
        var eatenCards = this._eatCards$1.toArray();
        eatenCards.add(card);
        var phoms = this._phomExtractor$1.extract(cardInHands, eatenCards);
        var canEat = phoms.get_count() > 0;
        return canEat;
    },
    
    _checkEatSimple$1: function Games_Tala_Parts_Fb_FbTablePart$_checkEatSimple$1(cardId) {
        /// <param name="cardId" type="Number" integer="true">
        /// </param>
        /// <returns type="Boolean"></returns>
        if (!Games.Tala.TalaState.current.get_isPlaying()) {
            return false;
        }
        if (!Games.Tala.TalaState.current.get_isYourTurn()) {
            return false;
        }
        if (cardId !== this._lastCard$1) {
            return false;
        }
        var cards = Games.Base.Components.CardInHand.instance.get_cards();
        if (cards.contains(cardId)) {
            return false;
        }
        return true;
    },
    
    inActive: function Games_Tala_Parts_Fb_FbTablePart$inActive() {
    },
    
    init: function Games_Tala_Parts_Fb_FbTablePart$init(container) {
        /// <param name="container" type="ZeroScript.Core.Games.IComponentContainer">
        /// </param>
        Games.Tala.Parts.Fb.FbTablePart.callBase(this, 'init', [ container ]);
        this.set_width(Games.Tala.Parts.Fb.FbConstant.viewWidth);
        this.set_height(Games.Tala.Parts.Fb.FbConstant.viewHeight);
        var manager = container.get_contentManager();
        var suiteImg = manager.createImageFromUrl(Games.Tala.Parts.Fb.FbTablePart._cardSuiteUrl$1);
        var downImage = manager.createImage(suiteImg, 0, 4 * Games.Tala.Parts.Fb.FbConstant.cardHeight, Games.Tala.Parts.Fb.FbConstant.cardWidth, Games.Tala.Parts.Fb.FbConstant.cardHeight);
        var highLight = manager.createImageFromUrl(Games.Tala.Parts.Fb.FbTablePart._highLightUrl$1);
        var eat = manager.createImageFromUrl(Games.Tala.Parts.Fb.FbTablePart._eatImgUrl$1);
        var marker = manager.createImageFromUrl(Games.Tala.Parts.Fb.FbTablePart._markerImgUrl$1);
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            this._phoms$1[i] = new Games.Tala.Parts.Fb.SlotPhom(i);
            var phom = this._phoms$1[i];
            phom.set_x(Games.Tala.Parts.Fb.FbConstant.groupPhomX[i]);
            phom.set_y(Games.Tala.Parts.Fb.FbConstant.groupPhomY[i]);
            phom.set_width(Games.Tala.Parts.Fb.FbConstant.cardWidth * 3);
            phom.set_height(Games.Tala.Parts.Fb.FbConstant.cardHeight * 2);
            phom.add_phomClick(Delegate.create(this, this._onPhomClick$1));
            this.add(phom);
        }
        this._view$1 = new Games.Tala.Parts.Fb._fbTableView();
        this._view$1.set_width(this.get_width());
        this._view$1.set_height(this.get_height());
        this.add(this._view$1);
        this._view$1.add_confirmShow(Delegate.create(this, this._onAutoHaThenAttack$1));
        this._view$1.add_cancelShow(Delegate.create(this, this._onCancelHa$1));
        this._view$1.add_confirmEat(Delegate.create(this, this._onConfirmEat$1));
        var suite = new Games.Base.Components.CardSuite(suiteImg, downImage, Games.Tala.Parts.Fb.FbConstant.cardWidth, Games.Tala.Parts.Fb.FbConstant.cardHeight, highLight, eat, marker);
        suite.set_width(this.get_width());
        suite.set_height(this.get_height());
        suite.set_x(0);
        suite.set_y(0);
        suite.map(Delegate.create(this, this._mapTaLaCards$1));
        this.add(suite);
    },
    
    _onConfirmEat$1: function Games_Tala_Parts_Fb_FbTablePart$_onConfirmEat$1() {
        Games.Base.GameRequest.send('Eat.htm');
    },
    
    _onCancelHa$1: function Games_Tala_Parts_Fb_FbTablePart$_onCancelHa$1() {
        Games.Base.GameRequest.send('Move.htm', 'cards', [ this._selectedCard$1 ]);
    },
    
    _onAutoHaThenAttack$1: function Games_Tala_Parts_Fb_FbTablePart$_onAutoHaThenAttack$1() {
        var attackCard = [ this._selectedCard$1 ];
        var guiString = '';
        for (var i = 0; i < this._guis$1.get_count(); i++) {
            var g = this._guis$1.get_item(i);
            if (g != null) {
                guiString += String.format('{0},{1},{2},', g.get_card(), g.get_phomId(), g.get_phomOwnerId());
            }
        }
        if (isNullOrUndefined(this._phomShow$1) || this._phomShow$1.get_count() === 0) {
            for (var i = 0; i < this._guis$1.get_count(); i++) {
                var g = this._guis$1.get_item(i);
                if (g != null) {
                    Games.Base.GameRequest.send('LiveOn.htm', 'cards', g.get_card(), 'phomId', g.get_phomId(), 'targetId', g.get_phomOwnerId());
                }
            }
            Games.Base.GameRequest.send('Move.htm', 'cards', attackCard);
        }
        else {
            var p0 = (isNullOrUndefined(this._phomShow$1.get_item(0))) ? new Array(0) : (this._phomShow$1.get_item(0)).toArray();
            var p1 = (isNullOrUndefined(this._phomShow$1.get_item(1))) ? new Array(1) : (this._phomShow$1.get_item(1)).toArray();
            var p2 = (isNullOrUndefined(this._phomShow$1.get_item(2))) ? new Array(2) : (this._phomShow$1.get_item(2)).toArray();
            Games.Base.GameRequest.send('ShowThenAttack.htm', 'cards', attackCard, 'phom0', p0.toString(), 'phom1', p1.toString(), 'phom2', p2.toString(), 'guis', guiString);
        }
    },
    
    _onPhomClick$1: function Games_Tala_Parts_Fb_FbTablePart$_onPhomClick$1(phomId, ownerId) {
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        /// <param name="ownerId" type="Number" integer="true">
        /// </param>
        var cards = Games.Base.Components.CardInHand.instance.getSelectedCards();
        Games.Base.GameRequest.send('LiveOn.htm', 'cards', cards.toArray(), 'phomId', phomId, 'targetId', ownerId);
    },
    
    _mapTaLaCards$1: function Games_Tala_Parts_Fb_FbTablePart$_mapTaLaCards$1(x, y) {
        /// <param name="x" type="Number" integer="true">
        /// </param>
        /// <param name="y" type="Number" integer="true">
        /// </param>
        /// <returns type="Number" integer="true"></returns>
        return Games.Tala.Parts.Fb.FbTablePart._cardType$1[y] * 13 + x;
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.Parts.Fb.PhomGroup

Games.Tala.Parts.Fb.PhomGroup = function Games_Tala_Parts_Fb_PhomGroup(expandDirection) {
    /// <param name="expandDirection" type="Games.Base.Components.ExpandDirect">
    /// </param>
    /// <field name="_dur$1" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="_cards$1" type="ZeroScript.Core.List">
    /// </field>
    /// <field name="_space$1" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="_expandDirection$1" type="Games.Base.Components.ExpandDirect">
    /// </field>
    /// <field name="_cardHeight$1" type="Number" integer="true">
    /// </field>
    /// <field name="_cardWidth$1" type="Number" integer="true">
    /// </field>
    /// <field name="ownerId" type="Number" integer="true">
    /// </field>
    /// <field name="phomId" type="Number" integer="true">
    /// </field>
    /// <field name="seatIndex" type="Number" integer="true">
    /// </field>
    /// <field name="pos" type="Number" integer="true">
    /// </field>
    /// <field name="eatenCard" type="Number" integer="true">
    /// </field>
    this._cards$1 = new ZeroScript.Core.List();
    this.ownerId = -1;
    this.phomId = -1;
    this.seatIndex = -1;
    this.pos = -1;
    this.eatenCard = -1;
    Games.Tala.Parts.Fb.PhomGroup.constructBase(this);
    this._expandDirection$1 = expandDirection;
    this._cardWidth$1 = Games.Base.Components.CardSuite.instance.get_cardWidth();
    this._cardHeight$1 = Games.Base.Components.CardSuite.instance.get_cardHeight();
    this.set_width(12 * Games.Tala.Parts.Fb.PhomGroup._space$1 + this._cardWidth$1);
    this.set_height(this._cardHeight$1);
}
Games.Tala.Parts.Fb.PhomGroup.prototype = {
    _expandDirection$1: 0,
    _cardHeight$1: 0,
    _cardWidth$1: 0,
    
    get_cards: function Games_Tala_Parts_Fb_PhomGroup$get_cards() {
        /// <value type="ZeroScript.Core.List"></value>
        return this._cards$1;
    },
    
    internalDraw: function Games_Tala_Parts_Fb_PhomGroup$internalDraw(canvas) {
        /// <param name="canvas" type="ZeroScript.Core.Games.ICanvas">
        /// </param>
        canvas.clear();
        if (this._expandDirection$1 === Games.Base.Components.ExpandDirect.right) {
            for (var i = 0; i < this._cards$1.get_count(); i++) {
                var card = Games.Base.Components.CardSuite.instance.get_faceUpImgs()[this._cards$1.get_item(i)];
                canvas.draw(card, Games.Tala.Parts.Fb.PhomGroup._space$1 * i, 0, this._cardWidth$1, this._cardHeight$1, 0, 1);
            }
        }
        else {
            for (var i = this._cards$1.get_count() - 1; i >= 0; i--) {
                var card = Games.Base.Components.CardSuite.instance.get_faceUpImgs()[this._cards$1.get_item(i)];
                canvas.draw(card, this.get_width() - (this._cardWidth$1 + Games.Tala.Parts.Fb.PhomGroup._space$1 * i), 0, this._cardWidth$1, this._cardHeight$1, 0, 1);
            }
        }
    },
    
    attachCard: function Games_Tala_Parts_Fb_PhomGroup$attachCard(card, phomId, phomOwnerId, fromX, fromY) {
        /// <param name="card" type="Number" integer="true">
        /// </param>
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        /// <param name="phomOwnerId" type="Number" integer="true">
        /// </param>
        /// <param name="fromX" type="Number" integer="true">
        /// </param>
        /// <param name="fromY" type="Number" integer="true">
        /// </param>
        var cards = new ZeroScript.Core.List();
        cards.add(card);
        this.attachCards(cards, phomId, phomOwnerId, fromX, fromY);
    },
    
    attachCards: function Games_Tala_Parts_Fb_PhomGroup$attachCards(cards, phomId, phomOwnerId, fromX, fromY) {
        /// <param name="cards" type="ZeroScript.Core.List">
        /// </param>
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        /// <param name="phomOwnerId" type="Number" integer="true">
        /// </param>
        /// <param name="fromX" type="Number" integer="true">
        /// </param>
        /// <param name="fromY" type="Number" integer="true">
        /// </param>
        this.phomId = phomId;
        this.ownerId = phomOwnerId;
        for (var i = 0; i < cards.get_count(); i++) {
            var card = Games.Base.Components.CardSuite.instance.get(cards.get_item(i));
            card.bringToFront();
            if (this._expandDirection$1 === Games.Base.Components.ExpandDirect.right) {
                card.move(fromX, fromY, this.get_absolutePosition().x + this.get_x() + Games.Tala.Parts.Fb.PhomGroup._space$1 * i, this.get_absolutePosition().y, Games.Tala.Parts.Fb.PhomGroup._dur$1);
            }
            else {
                card.move(fromX, fromY, this.get_absolutePosition().x + this.get_width() - (this._cardWidth$1 + Games.Tala.Parts.Fb.PhomGroup._space$1 * i), this.get_absolutePosition().y, Games.Tala.Parts.Fb.PhomGroup._dur$1);
            }
            if (!this._cards$1.contains(card.get_cardId())) {
                this._cards$1.add(card.get_cardId());
            }
        }
        window.setTimeout(Delegate.create(this, function() {
            for (var i = 0; i < cards.get_count(); i++) {
                var card = Games.Base.Components.CardSuite.instance.get(cards.get_item(i));
                card.set_visible(false);
            }
            this.redraw();
        }), Games.Tala.Parts.Fb.PhomGroup._dur$1);
    },
    
    clearCards: function Games_Tala_Parts_Fb_PhomGroup$clearCards() {
        this._cards$1.clear();
        this.phomId = -1;
        this.ownerId = -1;
        this.eatenCard = -1;
        this.redraw();
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.Parts.Fb.Picker

Games.Tala.Parts.Fb.Picker = function Games_Tala_Parts_Fb_Picker(facedown, bgCounter, counter) {
    /// <param name="facedown" type="ZeroScript.Core.Games.Image">
    /// </param>
    /// <param name="bgCounter" type="ZeroScript.Core.Games.Image">
    /// </param>
    /// <param name="counter" type="Object" domElement="true">
    /// </param>
    /// <field name="_fly$1" type="ZeroScript.Core.Games.ImageComponent">
    /// </field>
    /// <field name="_facedown$1" type="ZeroScript.Core.Games.Image">
    /// </field>
    /// <field name="_bgCounter$1" type="ZeroScript.Core.Games.Image">
    /// </field>
    /// <field name="_counter$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_hideCounter$1" type="Boolean">
    /// </field>
    Games.Tala.Parts.Fb.Picker.constructBase(this);
    this._facedown$1 = facedown;
    this._bgCounter$1 = bgCounter;
    this._counter$1 = counter;
    this._hideCounter$1 = true;
}
Games.Tala.Parts.Fb.Picker.prototype = {
    _fly$1: null,
    _facedown$1: null,
    _bgCounter$1: null,
    _counter$1: null,
    _hideCounter$1: false,
    
    loadContentCompleted: function Games_Tala_Parts_Fb_Picker$loadContentCompleted() {
        this._fly$1 = new ZeroScript.Core.Games.ImageComponent(this._facedown$1);
        this._fly$1.set_x(0);
        this._fly$1.set_y(0);
        this._fly$1.set_visible(false);
        this.add(this._fly$1);
        Games.Tala.Parts.Fb.Picker.callBase(this, 'loadContentCompleted');
    },
    
    get_count: function Games_Tala_Parts_Fb_Picker$get_count() {
        /// <value type="Number" integer="true"></value>
        return -1;
    },
    set_count: function Games_Tala_Parts_Fb_Picker$set_count(value) {
        /// <value type="Number" integer="true"></value>
        if (value > 0) {
            this._counter$1.innerText = (value < 10) ? '0' + value : value.toString();
            this.set_hideCounter(false);
        }
        else {
            this.set_hideCounter(true);
        }
        return value;
    },
    
    get_hideCounter: function Games_Tala_Parts_Fb_Picker$get_hideCounter() {
        /// <value type="Boolean"></value>
        return this._hideCounter$1;
    },
    set_hideCounter: function Games_Tala_Parts_Fb_Picker$set_hideCounter(value) {
        /// <value type="Boolean"></value>
        if (this._hideCounter$1 === value) {
            return;
        }
        this._hideCounter$1 = value;
        if (this._hideCounter$1) {
            ZeroScript.Core.DomHelper.visible(this._counter$1, false);
        }
        else {
            ZeroScript.Core.DomHelper.visible(this._counter$1, true);
        }
        this.needRedraw = true;
        return value;
    },
    
    flyTo: function Games_Tala_Parts_Fb_Picker$flyTo(toX, toY) {
        /// <param name="toX" type="Number" integer="true">
        /// </param>
        /// <param name="toY" type="Number" integer="true">
        /// </param>
        /// <returns type="ZeroScript.Core.Games.IAnimation"></returns>
        this._fly$1.set_visible(true);
        return this._fly$1.move(0, 0, toX - this.get_x(), toY - this.get_y(), 500);
    },
    
    internalDraw: function Games_Tala_Parts_Fb_Picker$internalDraw(canvas) {
        /// <param name="canvas" type="ZeroScript.Core.Games.ICanvas">
        /// </param>
        canvas.draw(this._facedown$1, 0, 0, this._facedown$1.width, this._facedown$1.height, 0, 1);
        if (this.get_hideCounter()) {
            return;
        }
        canvas.draw(this._bgCounter$1, 8, 13, this._bgCounter$1.width, this._bgCounter$1.height, 0, 1);
    },
    
    hideFly: function Games_Tala_Parts_Fb_Picker$hideFly() {
        this._fly$1.set_visible(false);
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.Parts.Fb.PlayerView

Games.Tala.Parts.Fb.PlayerView = function Games_Tala_Parts_Fb_PlayerView(slot, bus) {
    /// <param name="slot" type="Number" integer="true">
    /// </param>
    /// <param name="bus" type="ZeroScript.Core.IBus">
    /// </param>
    /// <field name="_userInfo" type="Object" domElement="true">
    /// </field>
    /// <field name="_name" type="Object" domElement="true">
    /// </field>
    /// <field name="_host" type="Object" domElement="true">
    /// </field>
    /// <field name="_avatar" type="Object" domElement="true">
    /// </field>
    /// <field name="_money" type="Object" domElement="true">
    /// </field>
    /// <field name="_level" type="Object" domElement="true">
    /// </field>
    /// <field name="_bus" type="ZeroScript.Core.IBus">
    /// </field>
    /// <field name="_user" type="Games.Base.Data.User">
    /// </field>
    this._bus = bus;
    this._userInfo = document.getElementById('user_info' + slot);
    var root = ZeroScript.Core.JQuery.JQueryHelper.select('#user_info' + slot);
    this._name = root.find('.name')[0];
    this._avatar = root.find('.avatar img')[0];
    this._host = root.find('.host_user')[0];
    this._money = root.find('.money')[0];
    this._level = root.find('.timebar .timebar_level')[0];
    EventHelper.attachEvent(this._avatar, EventHelper.click, Delegate.create(this, this._onClick));
    bus.subcribe('user.money', Delegate.create(this, this._onUpdateMoney));
    bus.subcribe('user.level', Delegate.create(this, this._onUpdateLevel));
    this.clear();
}
Games.Tala.Parts.Fb.PlayerView.prototype = {
    _userInfo: null,
    _name: null,
    _host: null,
    _avatar: null,
    _money: null,
    _level: null,
    _bus: null,
    _user: null,
    
    _onUpdateLevel: function Games_Tala_Parts_Fb_PlayerView$_onUpdateLevel(u) {
        /// <param name="u" type="Games.Base.Data.User">
        /// </param>
        if (this._user == null || u.id !== this._user.id) {
            return;
        }
        var level = u.statics.level;
        this._level.innerHTML = String.format('Level: <span>{0}</span>', level);
        var clazz = Math.floor(level / 10) * 10;
        this._level.className = String.format('timebar_level _{0}', clazz);
    },
    
    _onUpdateMoney: function Games_Tala_Parts_Fb_PlayerView$_onUpdateMoney(u) {
        /// <param name="u" type="Games.Base.Data.User">
        /// </param>
        if (this._user == null || u.id !== this._user.id) {
            return;
        }
        this._money.innerHTML = Format.compactCurrency(u.statics.money);
    },
    
    _onClick: function Games_Tala_Parts_Fb_PlayerView$_onClick(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        if (this._user == null) {
            return;
        }
        this._bus.publish('showProfile', this._user);
    },
    
    _displayMe: function Games_Tala_Parts_Fb_PlayerView$_displayMe(visible) {
        /// <param name="visible" type="Boolean">
        /// </param>
        ZeroScript.Core.DomHelper.visible(this._userInfo, visible);
    },
    
    get_user: function Games_Tala_Parts_Fb_PlayerView$get_user() {
        /// <value type="Games.Base.Data.User"></value>
        return this._user;
    },
    set_user: function Games_Tala_Parts_Fb_PlayerView$set_user(value) {
        /// <value type="Games.Base.Data.User"></value>
        this._user = value;
        var b = this._user != null;
        this._displayMe(b);
        if (b) {
            var users = [ this._user ];
            this._bus.publish('user.updateAvatars', users);
            this._bus.publish('user.updateProfiles', users);
            this._avatar.src = this._user.avatar;
            this._bus.publish('user.updateMoney', users);
            this._bus.publish('user.updateLevel', users);
        }
        this._name.innerHTML = (b) ? this._user.firstName : '';
        return value;
    },
    
    clear: function Games_Tala_Parts_Fb_PlayerView$clear() {
        this.set_user(null);
    },
    
    show: function Games_Tala_Parts_Fb_PlayerView$show() {
        ZeroScript.Core.DomHelper.visible(this._userInfo, true);
    },
    
    hide: function Games_Tala_Parts_Fb_PlayerView$hide() {
        ZeroScript.Core.DomHelper.visible(this._userInfo, false);
    },
    
    showHost: function Games_Tala_Parts_Fb_PlayerView$showHost(isHost) {
        /// <param name="isHost" type="Boolean">
        /// </param>
        ZeroScript.Core.DomHelper.visible(this._host, isHost);
    },
    
    get_showLevel: function Games_Tala_Parts_Fb_PlayerView$get_showLevel() {
        /// <value type="Boolean"></value>
        return false;
    },
    set_showLevel: function Games_Tala_Parts_Fb_PlayerView$set_showLevel(value) {
        /// <value type="Boolean"></value>
        ZeroScript.Core.DomHelper.visible(this._level, value);
        return value;
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.Parts.Fb.SlotCard

Games.Tala.Parts.Fb.SlotCard = function Games_Tala_Parts_Fb_SlotCard(slot) {
    /// <param name="slot" type="Number" integer="true">
    /// </param>
    /// <field name="_slot$1" type="Number" integer="true">
    /// </field>
    /// <field name="_handX$1" type="Number" integer="true">
    /// </field>
    /// <field name="_handY$1" type="Number" integer="true">
    /// </field>
    /// <field name="_holder$1" type="Games.Base.Components.FacedownHolder">
    /// </field>
    Games.Tala.Parts.Fb.SlotCard.constructBase(this);
    this._slot$1 = slot;
    this._handX$1 = Games.Tala.Parts.Fb.FbConstant.handXs[slot];
    this._handY$1 = Games.Tala.Parts.Fb.FbConstant.handYs[slot];
}
Games.Tala.Parts.Fb.SlotCard.prototype = {
    _slot$1: 0,
    _handX$1: 0,
    _handY$1: 0,
    _holder$1: null,
    
    loadContent: function Games_Tala_Parts_Fb_SlotCard$loadContent() {
        Games.Tala.Parts.Fb.SlotCard.callBase(this, 'loadContent');
        var faceDownH = this.get_container().get_contentManager().createImageFromUrl('_Resources/TaLa/img/facedown.png');
        this._holder$1 = new Games.Base.Components.FacedownHolder(Games.Base.Components.CardSuite.instance.get_faceDownImage(), Games.Base.Components.CardSuite.instance.get_faceDownImage(), 5, 5, 15, 15, 10, Games.Tala.Parts.Fb.FbConstant.directions[this._slot$1]);
        this._holder$1.set_size(0);
        this._holder$1.set_visible(true);
        this._holder$1.set_x(this._handX$1);
        this._holder$1.set_y(this._handY$1);
        this.add(this._holder$1);
    },
    
    puzzle: function Games_Tala_Parts_Fb_SlotCard$puzzle() {
        this._holder$1.puzzle(9);
    },
    
    attack: function Games_Tala_Parts_Fb_SlotCard$attack(count) {
        /// <param name="count" type="Number" integer="true">
        /// </param>
        this._holder$1.set_size(this._holder$1.get_size() - count);
    },
    
    resetParams: function Games_Tala_Parts_Fb_SlotCard$resetParams() {
        this._holder$1.set_size(0);
        this._holder$1.set_x(this._handX$1);
        this._holder$1.set_y(this._handY$1);
    },
    
    showCards: function Games_Tala_Parts_Fb_SlotCard$showCards(cards) {
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        this._holder$1.set_size(0);
        this._holder$1.flip(cards);
    },
    
    pick: function Games_Tala_Parts_Fb_SlotCard$pick(seat) {
        /// <param name="seat" type="Number" integer="true">
        /// </param>
        this._holder$1.set_size(this._holder$1.get_size() + 1);
    },
    
    eat: function Games_Tala_Parts_Fb_SlotCard$eat(card) {
        /// <param name="card" type="Number" integer="true">
        /// </param>
        this._holder$1.set_size(this._holder$1.get_size() + 1);
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.Parts.Fb.SlotPhom

Games.Tala.Parts.Fb.SlotPhom = function Games_Tala_Parts_Fb_SlotPhom(slot) {
    /// <param name="slot" type="Number" integer="true">
    /// </param>
    /// <field name="_phoms$1" type="Array" elementType="PhomGroup">
    /// </field>
    /// <field name="_slot$1" type="Number" integer="true">
    /// </field>
    /// <field name="_handX$1" type="Number" integer="true">
    /// </field>
    /// <field name="_handY$1" type="Number" integer="true">
    /// </field>
    /// <field name="__phomClick$1" type="Games.Tala.PhomClick">
    /// </field>
    this._phoms$1 = new Array(3);
    Games.Tala.Parts.Fb.SlotPhom.constructBase(this);
    this._slot$1 = slot;
    this._handX$1 = Games.Tala.Parts.Fb.FbConstant.handXs[slot];
    this._handY$1 = Games.Tala.Parts.Fb.FbConstant.handYs[slot];
}
Games.Tala.Parts.Fb.SlotPhom.prototype = {
    _slot$1: 0,
    _handX$1: 0,
    _handY$1: 0,
    
    loadContent: function Games_Tala_Parts_Fb_SlotPhom$loadContent() {
        Games.Tala.Parts.Fb.SlotPhom.callBase(this, 'loadContent');
        for (var i = 0; i < 3; i++) {
            this._phoms$1[i] = new Games.Tala.Parts.Fb.PhomGroup(Games.Tala.Parts.Fb.FbConstant.expands[this._slot$1]);
            var phom = this._phoms$1[i];
            phom.set_width(Games.Tala.Parts.Fb.FbConstant.cardWidth * 3);
            phom.set_height(Games.Tala.Parts.Fb.FbConstant.cardHeight);
            phom.seatIndex = this._slot$1;
            phom.pos = i;
            phom.set_x(Games.Tala.Parts.Fb.FbConstant.cardDaHaX[this._slot$1][i]);
            phom.set_y(Games.Tala.Parts.Fb.FbConstant.cardDaHaY[this._slot$1][i]);
            phom.add_click(Delegate.create(this, this._onPhomClick$1));
        }
        var order = Games.Tala.Parts.Fb.FbConstant.orders[this._slot$1];
        for (var i = 0; i < order.length; i++) {
            var tmp = order[i];
            this.add(this._phoms$1[tmp]);
        }
    },
    
    add_phomClick: function Games_Tala_Parts_Fb_SlotPhom$add_phomClick(value) {
        /// <param name="value" type="Function" />
        this.__phomClick$1 = Delegate.combine(this.__phomClick$1, value);
    },
    remove_phomClick: function Games_Tala_Parts_Fb_SlotPhom$remove_phomClick(value) {
        /// <param name="value" type="Function" />
        this.__phomClick$1 = Delegate.remove(this.__phomClick$1, value);
    },
    
    __phomClick$1: null,
    
    _onPhomClick$1: function Games_Tala_Parts_Fb_SlotPhom$_onPhomClick$1(sender, x, y) {
        /// <param name="sender" type="ZeroScript.Core.Games.IComponent">
        /// </param>
        /// <param name="x" type="Number" integer="true">
        /// </param>
        /// <param name="y" type="Number" integer="true">
        /// </param>
        var phom = sender;
        if (this.__phomClick$1 != null) {
            this.__phomClick$1.invoke(phom.phomId, phom.ownerId);
        }
    },
    
    _getNextEmptyPhom$1: function Games_Tala_Parts_Fb_SlotPhom$_getNextEmptyPhom$1() {
        /// <returns type="Games.Tala.Parts.Fb.PhomGroup"></returns>
        for (var i = 0; i < 3; i++) {
            var p = this._phoms$1[i];
            if (p.eatenCard === -1 && p.get_cards().get_count() === 0) {
                return p;
            }
        }
        return null;
    },
    
    showPhom: function Games_Tala_Parts_Fb_SlotPhom$showPhom(cards, phomId, ownerId) {
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        /// <param name="ownerId" type="Number" integer="true">
        /// </param>
        var p = null;
        p = this._getPhomByEatCard$1(cards);
        if (p == null) {
            p = this._getNextEmptyPhom$1();
        }
        p.set_visible(true);
        p.attachCards(new ZeroScript.Core.List(cards), phomId, ownerId, this._handX$1, this._handY$1);
    },
    
    _getPhomByEatCard$1: function Games_Tala_Parts_Fb_SlotPhom$_getPhomByEatCard$1(cards) {
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        /// <returns type="Games.Tala.Parts.Fb.PhomGroup"></returns>
        var list = new ZeroScript.Core.List(cards);
        for (var i = 0; i < 3; i++) {
            var p = this._phoms$1[i];
            if (list.contains(p.eatenCard)) {
                return p;
            }
        }
        return null;
    },
    
    gui: function Games_Tala_Parts_Fb_SlotPhom$gui(cards, fromSeat, phomId) {
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        /// <param name="fromSeat" type="Number" integer="true">
        /// </param>
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        var p = this._getPhomById$1(phomId);
        var x = Games.Tala.Parts.Fb.FbConstant.handXs[fromSeat];
        var y = Games.Tala.Parts.Fb.FbConstant.handYs[fromSeat];
        if (p == null) {
            return;
        }
        p.attachCards(new ZeroScript.Core.List(cards), phomId, p.ownerId, x, y);
    },
    
    eat: function Games_Tala_Parts_Fb_SlotPhom$eat(card) {
        /// <param name="card" type="Number" integer="true">
        /// </param>
        var c = Games.Base.Components.CardSuite.instance.get(card);
        var phom = this._getNextEmptyPhom$1();
        phom.set_visible(true);
        phom.eatenCard = card;
        phom.attachCard(card, -1, -1, c.get_x(), c.get_y());
    },
    
    _getPhomById$1: function Games_Tala_Parts_Fb_SlotPhom$_getPhomById$1(phomId) {
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        /// <returns type="Games.Tala.Parts.Fb.PhomGroup"></returns>
        for (var i = 0; i < 3; i++) {
            var p = this._phoms$1[i];
            if (p.phomId === phomId) {
                return p;
            }
        }
        return null;
    },
    
    resetParams: function Games_Tala_Parts_Fb_SlotPhom$resetParams() {
        for (var i = 0; i < 3; i++) {
            this._phoms$1[i].set_visible(false);
            this._phoms$1[i].clearCards();
        }
    }
}


Type.createNamespace('Games.Tala.vnz');

////////////////////////////////////////////////////////////////////////////////
// Games.Tala.vnz.ActionView

Games.Tala.vnz.ActionView = function Games_Tala_vnz_ActionView() {
    /// <field name="_attack" type="Object" domElement="true">
    /// </field>
    /// <field name="_sort" type="Object" domElement="true">
    /// </field>
    /// <field name="_u" type="Object" domElement="true">
    /// </field>
    /// <field name="_show" type="Object" domElement="true">
    /// </field>
    /// <field name="_state" type="Games.Tala.ActionState">
    /// </field>
    /// <field name="__attack" type="Callback">
    /// </field>
    /// <field name="__sort" type="Callback">
    /// </field>
    /// <field name="__show" type="Callback">
    /// </field>
    /// <field name="__u" type="Callback">
    /// </field>
    this._state = Games.Tala.ActionState.start;
    this._initDoms();
    this._initEvents();
}
Games.Tala.vnz.ActionView.prototype = {
    _attack: null,
    _sort: null,
    _u: null,
    _show: null,
    
    add_attack: function Games_Tala_vnz_ActionView$add_attack(value) {
        /// <param name="value" type="Function" />
        this.__attack = Delegate.combine(this.__attack, value);
    },
    remove_attack: function Games_Tala_vnz_ActionView$remove_attack(value) {
        /// <param name="value" type="Function" />
        this.__attack = Delegate.remove(this.__attack, value);
    },
    
    __attack: null,
    
    add_sort: function Games_Tala_vnz_ActionView$add_sort(value) {
        /// <param name="value" type="Function" />
        this.__sort = Delegate.combine(this.__sort, value);
    },
    remove_sort: function Games_Tala_vnz_ActionView$remove_sort(value) {
        /// <param name="value" type="Function" />
        this.__sort = Delegate.remove(this.__sort, value);
    },
    
    __sort: null,
    
    add_show: function Games_Tala_vnz_ActionView$add_show(value) {
        /// <param name="value" type="Function" />
        this.__show = Delegate.combine(this.__show, value);
    },
    remove_show: function Games_Tala_vnz_ActionView$remove_show(value) {
        /// <param name="value" type="Function" />
        this.__show = Delegate.remove(this.__show, value);
    },
    
    __show: null,
    
    add_u: function Games_Tala_vnz_ActionView$add_u(value) {
        /// <param name="value" type="Function" />
        this.__u = Delegate.combine(this.__u, value);
    },
    remove_u: function Games_Tala_vnz_ActionView$remove_u(value) {
        /// <param name="value" type="Function" />
        this.__u = Delegate.remove(this.__u, value);
    },
    
    __u: null,
    
    get_state: function Games_Tala_vnz_ActionView$get_state() {
        /// <value type="Games.Tala.ActionState"></value>
        return this._state;
    },
    set_state: function Games_Tala_vnz_ActionView$set_state(value) {
        /// <value type="Games.Tala.ActionState"></value>
        this._state = value;
        if (Games.Tala.TalaState.current.get_isViewer()) {
            this._hideAllActions();
            return;
        }
        switch (this._state) {
            case Games.Tala.ActionState.start:
                this._enable(this._attack, false);
                this._enable(this._show, false);
                this._enable(this._u, true);
                this._enable(this._sort, true);
                break;
            case Games.Tala.ActionState.eat:
            case Games.Tala.ActionState.pick:
                this._enable(this._attack, true);
                break;
            case Games.Tala.ActionState.lastTurn:
                this._enable(this._show, true);
                break;
            case Games.Tala.ActionState.u:
                this._enable(this._u, true);
                break;
            case Games.Tala.ActionState.yourTurn:
                var cards = Games.Base.Components.CardInHand.instance.get_cards();
                this._enable(this._attack, cards.get_count() === 10);
                break;
            case Games.Tala.ActionState.someOneTurn:
                this._enable(this._attack, false);
                this._enable(this._show, false);
                break;
        }
        return value;
    },
    
    _hideAllActions: function Games_Tala_vnz_ActionView$_hideAllActions() {
        ZeroScript.Core.DomHelper.visible(this._attack, false);
        ZeroScript.Core.DomHelper.visible(this._sort, false);
        ZeroScript.Core.DomHelper.visible(this._show, false);
        ZeroScript.Core.DomHelper.visible(this._u, false);
    },
    
    _initEvents: function Games_Tala_vnz_ActionView$_initEvents() {
        EventHelper.attachEvent(this._attack, EventHelper.click, Delegate.create(this, this._onAttack));
        EventHelper.attachEvent(this._sort, EventHelper.click, Delegate.create(this, this._onSort));
        EventHelper.attachEvent(this._show, EventHelper.click, Delegate.create(this, this._onShow));
        EventHelper.attachEvent(this._u, EventHelper.click, Delegate.create(this, this._onU));
    },
    
    _isEnable: function Games_Tala_vnz_ActionView$_isEnable(dom) {
        /// <param name="dom" type="Object" domElement="true">
        /// </param>
        /// <returns type="Boolean"></returns>
        var css = dom.className;
        return css.indexOf('enabled') >= 0;
    },
    
    _enable: function Games_Tala_vnz_ActionView$_enable(dom, enable) {
        /// <param name="dom" type="Object" domElement="true">
        /// </param>
        /// <param name="enable" type="Boolean">
        /// </param>
        if (isNullOrUndefined(dom)) {
            return;
        }
        ZeroScript.Core.DomHelper.visible(dom, true);
        var css = dom.className;
        if (!enable) {
            css = css.replace('enabled', 'disabled');
        }
        else {
            css = css.replace('disabled', 'enabled');
        }
        dom.className = css;
    },
    
    _onShow: function Games_Tala_vnz_ActionView$_onShow(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        if (!this._isEnable(this._show)) {
            return;
        }
        if (this.__show != null) {
            this.__show.invoke();
        }
    },
    
    _onU: function Games_Tala_vnz_ActionView$_onU(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        if (this.__u != null) {
            this.__u.invoke();
        }
    },
    
    _onSort: function Games_Tala_vnz_ActionView$_onSort(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        if (this.__sort != null) {
            this.__sort.invoke();
        }
    },
    
    _onAttack: function Games_Tala_vnz_ActionView$_onAttack(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        if (!this._isEnable(this._attack)) {
            return;
        }
        if (this.__attack != null) {
            this.__attack.invoke();
        }
    },
    
    _initDoms: function Games_Tala_vnz_ActionView$_initDoms() {
        this._attack = document.getElementById('button_attack');
        this._sort = document.getElementById('button_sort');
        this._show = document.getElementById('button_ha_bai');
        this._u = document.getElementById('button_u');
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.vnz.BubbleView

Games.Tala.vnz.BubbleView = function Games_Tala_vnz_BubbleView(dom) {
    /// <param name="dom" type="Object" domElement="true">
    /// </param>
    /// <field name="_commboTime" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="_autoHideTimeoutId" type="Number" integer="true">
    /// </field>
    /// <field name="_lastMsg" type="String">
    /// </field>
    /// <field name="_lastTime" type="Date">
    /// </field>
    /// <field name="_jElement" type="ZeroScript.Core.JQuery.IJQuery">
    /// </field>
    this._jElement = ZeroScript.Core.JQuery.JQueryHelper.select(dom);
}
Games.Tala.vnz.BubbleView.prototype = {
    _autoHideTimeoutId: 0,
    _lastMsg: null,
    _lastTime: null,
    _jElement: null,
    
    get_text: function Games_Tala_vnz_BubbleView$get_text() {
        /// <value type="String"></value>
        return this._jElement.html();
    },
    set_text: function Games_Tala_vnz_BubbleView$set_text(value) {
        /// <value type="String"></value>
        this._clearAutoHide();
        this._appendText(value);
        this._show();
        this._autoHide();
        return value;
    },
    
    setEmoticon: function Games_Tala_vnz_BubbleView$setEmoticon(mood) {
        /// <param name="mood" type="Number" integer="true">
        /// </param>
        var html = this._getRandomEmo(mood);
        this.set_text(html);
    },
    
    _getRandomEmo: function Games_Tala_vnz_BubbleView$_getRandomEmo(mood) {
        /// <param name="mood" type="Number" integer="true">
        /// </param>
        /// <returns type="String"></returns>
        var i = Math.round(Math.random() * 4) + 1;
        var t = (mood === Games.Base.Data.EmoticonData.happy) ? 'happy' : 'sad';
        return String.format('<i class=\'img_emo emo_{0}_{1}\'></i>', t, i);
    },
    
    _appendText: function Games_Tala_vnz_BubbleView$_appendText(value) {
        /// <param name="value" type="String">
        /// </param>
        var msg = Format.toChat(value);
        if (!String.isNullOrEmpty(this._lastMsg) && Date.get_now().getTime() - this._lastTime.getTime() < Games.Tala.vnz.BubbleView._commboTime) {
            msg = this._lastMsg + '<br/>' + msg;
        }
        this._jElement.html(msg);
        this._lastMsg = value;
        this._lastTime = Date.get_now();
    },
    
    _clearAutoHide: function Games_Tala_vnz_BubbleView$_clearAutoHide() {
        window.clearTimeout(this._autoHideTimeoutId);
    },
    
    _autoHide: function Games_Tala_vnz_BubbleView$_autoHide() {
        this._autoHideTimeoutId = window.setTimeout(Delegate.create(this, this._hide), 7 * 1000);
    },
    
    _hide: function Games_Tala_vnz_BubbleView$_hide() {
        this._jElement.hide();
        this._lastMsg = String.Empty;
    },
    
    _show: function Games_Tala_vnz_BubbleView$_show() {
        this._jElement.show();
    },
    
    clear: function Games_Tala_vnz_BubbleView$clear() {
        this._clearAutoHide();
        this._hide();
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.vnz.PhomGroup

Games.Tala.vnz.PhomGroup = function Games_Tala_vnz_PhomGroup(expandDirection) {
    /// <param name="expandDirection" type="Games.Base.Components.ExpandDirect">
    /// </param>
    /// <field name="_dur$1" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="_cards$1" type="ZeroScript.Core.List">
    /// </field>
    /// <field name="_space$1" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="_expandDirection$1" type="Games.Base.Components.ExpandDirect">
    /// </field>
    /// <field name="_cardHeight$1" type="Number" integer="true">
    /// </field>
    /// <field name="_cardWidth$1" type="Number" integer="true">
    /// </field>
    /// <field name="ownerId" type="Number" integer="true">
    /// </field>
    /// <field name="phomId" type="Number" integer="true">
    /// </field>
    /// <field name="seatIndex" type="Number" integer="true">
    /// </field>
    /// <field name="pos" type="Number" integer="true">
    /// </field>
    /// <field name="eatenCard" type="Number" integer="true">
    /// </field>
    this._cards$1 = new ZeroScript.Core.List();
    this.ownerId = -1;
    this.phomId = -1;
    this.seatIndex = -1;
    this.pos = -1;
    this.eatenCard = -1;
    Games.Tala.vnz.PhomGroup.constructBase(this);
    this._expandDirection$1 = expandDirection;
    this._cardWidth$1 = Games.Base.Components.CardSuite.instance.get_cardWidth();
    this._cardHeight$1 = Games.Base.Components.CardSuite.instance.get_cardHeight();
    this.set_width(12 * Games.Tala.vnz.PhomGroup._space$1 + this._cardWidth$1);
    this.set_height(this._cardHeight$1);
}
Games.Tala.vnz.PhomGroup.prototype = {
    _expandDirection$1: 0,
    _cardHeight$1: 0,
    _cardWidth$1: 0,
    
    get_cards: function Games_Tala_vnz_PhomGroup$get_cards() {
        /// <value type="ZeroScript.Core.List"></value>
        return this._cards$1;
    },
    
    internalDraw: function Games_Tala_vnz_PhomGroup$internalDraw(canvas) {
        /// <param name="canvas" type="ZeroScript.Core.Games.ICanvas">
        /// </param>
        canvas.clear();
        if (this._expandDirection$1 === Games.Base.Components.ExpandDirect.right) {
            for (var i = 0; i < this._cards$1.get_count(); i++) {
                var card = Games.Base.Components.CardSuite.instance.get_faceUpImgs()[this._cards$1.get_item(i)];
                canvas.draw(card, Games.Tala.vnz.PhomGroup._space$1 * i, 0, this._cardWidth$1, this._cardHeight$1, 0, 1);
            }
        }
        else {
            for (var i = this._cards$1.get_count() - 1; i >= 0; i--) {
                var card = Games.Base.Components.CardSuite.instance.get_faceUpImgs()[this._cards$1.get_item(i)];
                canvas.draw(card, this.get_width() - (this._cardWidth$1 + Games.Tala.vnz.PhomGroup._space$1 * i), 0, this._cardWidth$1, this._cardHeight$1, 0, 1);
            }
        }
    },
    
    attachCard: function Games_Tala_vnz_PhomGroup$attachCard(card, phomId, phomOwnerId, fromX, fromY) {
        /// <param name="card" type="Number" integer="true">
        /// </param>
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        /// <param name="phomOwnerId" type="Number" integer="true">
        /// </param>
        /// <param name="fromX" type="Number" integer="true">
        /// </param>
        /// <param name="fromY" type="Number" integer="true">
        /// </param>
        var cards = new ZeroScript.Core.List();
        cards.add(card);
        this.attachCards(cards, phomId, phomOwnerId, fromX, fromY);
    },
    
    attachCards: function Games_Tala_vnz_PhomGroup$attachCards(cards, phomId, phomOwnerId, fromX, fromY) {
        /// <param name="cards" type="ZeroScript.Core.List">
        /// </param>
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        /// <param name="phomOwnerId" type="Number" integer="true">
        /// </param>
        /// <param name="fromX" type="Number" integer="true">
        /// </param>
        /// <param name="fromY" type="Number" integer="true">
        /// </param>
        this.phomId = phomId;
        this.ownerId = phomOwnerId;
        for (var i = 0; i < cards.get_count(); i++) {
            var card = Games.Base.Components.CardSuite.instance.get(cards.get_item(i));
            card.bringToFront();
            if (this._expandDirection$1 === Games.Base.Components.ExpandDirect.right) {
                card.move(fromX, fromY, this.get_absolutePosition().x + this.get_x() + Games.Tala.vnz.PhomGroup._space$1 * i, this.get_absolutePosition().y, Games.Tala.vnz.PhomGroup._dur$1);
            }
            else {
                card.move(fromX, fromY, this.get_absolutePosition().x + this.get_width() - (this._cardWidth$1 + Games.Tala.vnz.PhomGroup._space$1 * i), this.get_absolutePosition().y, Games.Tala.vnz.PhomGroup._dur$1);
            }
            if (!this._cards$1.contains(card.get_cardId())) {
                this._cards$1.add(card.get_cardId());
            }
        }
        window.setTimeout(Delegate.create(this, function() {
            for (var i = 0; i < cards.get_count(); i++) {
                var card = Games.Base.Components.CardSuite.instance.get(cards.get_item(i));
                card.set_visible(false);
            }
            this.redraw();
        }), Games.Tala.vnz.PhomGroup._dur$1);
    },
    
    clearCards: function Games_Tala_vnz_PhomGroup$clearCards() {
        this._cards$1.clear();
        this.phomId = -1;
        this.ownerId = -1;
        this.eatenCard = -1;
        this.redraw();
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.vnz.Picker

Games.Tala.vnz.Picker = function Games_Tala_vnz_Picker(facedown, bgCounter, counter) {
    /// <param name="facedown" type="ZeroScript.Core.Games.Image">
    /// </param>
    /// <param name="bgCounter" type="ZeroScript.Core.Games.Image">
    /// </param>
    /// <param name="counter" type="Object" domElement="true">
    /// </param>
    /// <field name="_fly$1" type="ZeroScript.Core.Games.ImageComponent">
    /// </field>
    /// <field name="_facedown$1" type="ZeroScript.Core.Games.Image">
    /// </field>
    /// <field name="_bgCounter$1" type="ZeroScript.Core.Games.Image">
    /// </field>
    /// <field name="_counter$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_hideCounter$1" type="Boolean">
    /// </field>
    Games.Tala.vnz.Picker.constructBase(this);
    this._facedown$1 = facedown;
    this._bgCounter$1 = bgCounter;
    this._counter$1 = counter;
    this._hideCounter$1 = true;
}
Games.Tala.vnz.Picker.prototype = {
    _fly$1: null,
    _facedown$1: null,
    _bgCounter$1: null,
    _counter$1: null,
    _hideCounter$1: false,
    
    loadContentCompleted: function Games_Tala_vnz_Picker$loadContentCompleted() {
        this._fly$1 = new ZeroScript.Core.Games.ImageComponent(this._facedown$1);
        this._fly$1.set_x(0);
        this._fly$1.set_y(0);
        this._fly$1.set_visible(false);
        this.add(this._fly$1);
        Games.Tala.vnz.Picker.callBase(this, 'loadContentCompleted');
    },
    
    get_count: function Games_Tala_vnz_Picker$get_count() {
        /// <value type="Number" integer="true"></value>
        return -1;
    },
    set_count: function Games_Tala_vnz_Picker$set_count(value) {
        /// <value type="Number" integer="true"></value>
        if (value > 0) {
            this._counter$1.innerText = (value < 10) ? '0' + value : value.toString();
            this.set_hideCounter(false);
        }
        else {
            this.set_hideCounter(true);
        }
        return value;
    },
    
    get_hideCounter: function Games_Tala_vnz_Picker$get_hideCounter() {
        /// <value type="Boolean"></value>
        return this._hideCounter$1;
    },
    set_hideCounter: function Games_Tala_vnz_Picker$set_hideCounter(value) {
        /// <value type="Boolean"></value>
        if (this._hideCounter$1 === value) {
            return;
        }
        this._hideCounter$1 = value;
        if (this._hideCounter$1) {
            ZeroScript.Core.DomHelper.visible(this._counter$1, false);
        }
        else {
            ZeroScript.Core.DomHelper.visible(this._counter$1, true);
        }
        this.needRedraw = true;
        return value;
    },
    
    flyTo: function Games_Tala_vnz_Picker$flyTo(toX, toY) {
        /// <param name="toX" type="Number" integer="true">
        /// </param>
        /// <param name="toY" type="Number" integer="true">
        /// </param>
        /// <returns type="ZeroScript.Core.Games.IAnimation"></returns>
        this._fly$1.set_visible(true);
        return this._fly$1.move(0, 0, toX - this.get_x(), toY - this.get_y(), 500);
    },
    
    internalDraw: function Games_Tala_vnz_Picker$internalDraw(canvas) {
        /// <param name="canvas" type="ZeroScript.Core.Games.ICanvas">
        /// </param>
        canvas.draw(this._facedown$1, 0, 0, this._facedown$1.width, this._facedown$1.height, 0, 1);
        if (this.get_hideCounter()) {
            return;
        }
        canvas.draw(this._bgCounter$1, 8, 13, this._bgCounter$1.width, this._bgCounter$1.height, 0, 1);
    },
    
    hideFly: function Games_Tala_vnz_Picker$hideFly() {
        this._fly$1.set_visible(false);
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.vnz.PlayerView

Games.Tala.vnz.PlayerView = function Games_Tala_vnz_PlayerView(slot, bus) {
    /// <param name="slot" type="Number" integer="true">
    /// </param>
    /// <param name="bus" type="ZeroScript.Core.IBus">
    /// </param>
    /// <field name="_userInfo" type="Object" domElement="true">
    /// </field>
    /// <field name="_name" type="Object" domElement="true">
    /// </field>
    /// <field name="_host" type="Object" domElement="true">
    /// </field>
    /// <field name="_avatar" type="Object" domElement="true">
    /// </field>
    /// <field name="_money" type="Object" domElement="true">
    /// </field>
    /// <field name="_level" type="Object" domElement="true">
    /// </field>
    /// <field name="_bus" type="ZeroScript.Core.IBus">
    /// </field>
    /// <field name="_user" type="Games.Base.Data.User">
    /// </field>
    this._bus = bus;
    this._userInfo = document.getElementById('user_info' + slot);
    var root = ZeroScript.Core.JQuery.JQueryHelper.select('#user_info' + slot);
    this._name = root.find('.name')[0];
    this._avatar = root.find('.avatar img')[0];
    this._host = root.find('.host_user')[0];
    this._money = root.find('.money')[0];
    this._level = root.find('.timebar .timebar_level')[0];
    EventHelper.attachEvent(this._avatar, EventHelper.click, Delegate.create(this, this._onClick));
    bus.subcribe('user.money', Delegate.create(this, this._onUpdateMoney));
    bus.subcribe('user.level', Delegate.create(this, this._onUpdateLevel));
    this.clear();
}
Games.Tala.vnz.PlayerView.prototype = {
    _userInfo: null,
    _name: null,
    _host: null,
    _avatar: null,
    _money: null,
    _level: null,
    _bus: null,
    _user: null,
    
    _onUpdateLevel: function Games_Tala_vnz_PlayerView$_onUpdateLevel(u) {
        /// <param name="u" type="Games.Base.Data.User">
        /// </param>
        if (this._user == null || u.id !== this._user.id) {
            return;
        }
        var level = u.statics.level;
        this._level.innerHTML = String.format('Level: <span>{0}</span>', level);
        var clazz = Math.floor(level / 10) * 10;
        this._level.className = String.format('timebar_level _{0}', clazz);
    },
    
    _onUpdateMoney: function Games_Tala_vnz_PlayerView$_onUpdateMoney(u) {
        /// <param name="u" type="Games.Base.Data.User">
        /// </param>
        if (this._user == null || u.id !== this._user.id) {
            return;
        }
        this._money.innerHTML = Format.compactCurrency(u.statics.money);
    },
    
    _onClick: function Games_Tala_vnz_PlayerView$_onClick(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        if (this._user == null) {
            return;
        }
        this._bus.publish('showProfile', this._user);
    },
    
    _displayMe: function Games_Tala_vnz_PlayerView$_displayMe(visible) {
        /// <param name="visible" type="Boolean">
        /// </param>
        ZeroScript.Core.DomHelper.visible(this._userInfo, visible);
    },
    
    get_user: function Games_Tala_vnz_PlayerView$get_user() {
        /// <value type="Games.Base.Data.User"></value>
        return this._user;
    },
    set_user: function Games_Tala_vnz_PlayerView$set_user(value) {
        /// <value type="Games.Base.Data.User"></value>
        this._user = value;
        var b = this._user != null;
        this._displayMe(b);
        if (b) {
            var users = [ this._user ];
            this._bus.publish('user.updateAvatars', users);
            this._bus.publish('user.updateProfiles', users);
            this._avatar.src = this._user.avatar;
            this._bus.publish('user.updateMoney', users);
            this._bus.publish('user.updateLevel', users);
        }
        this._name.innerHTML = (b) ? this._user.firstName : '';
        return value;
    },
    
    clear: function Games_Tala_vnz_PlayerView$clear() {
        this.set_user(null);
    },
    
    show: function Games_Tala_vnz_PlayerView$show() {
        ZeroScript.Core.DomHelper.visible(this._userInfo, true);
    },
    
    hide: function Games_Tala_vnz_PlayerView$hide() {
        ZeroScript.Core.DomHelper.visible(this._userInfo, false);
    },
    
    showHost: function Games_Tala_vnz_PlayerView$showHost(isHost) {
        /// <param name="isHost" type="Boolean">
        /// </param>
        ZeroScript.Core.DomHelper.visible(this._host, isHost);
    },
    
    get_showLevel: function Games_Tala_vnz_PlayerView$get_showLevel() {
        /// <value type="Boolean"></value>
        return false;
    },
    set_showLevel: function Games_Tala_vnz_PlayerView$set_showLevel(value) {
        /// <value type="Boolean"></value>
        ZeroScript.Core.DomHelper.visible(this._level, value);
        return value;
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.vnz.SlotCard

Games.Tala.vnz.SlotCard = function Games_Tala_vnz_SlotCard(slot) {
    /// <param name="slot" type="Number" integer="true">
    /// </param>
    /// <field name="_slot$1" type="Number" integer="true">
    /// </field>
    /// <field name="_handX$1" type="Number" integer="true">
    /// </field>
    /// <field name="_handY$1" type="Number" integer="true">
    /// </field>
    /// <field name="_holder$1" type="Games.Base.Components.FacedownHolder">
    /// </field>
    Games.Tala.vnz.SlotCard.constructBase(this);
    this._slot$1 = slot;
    this._handX$1 = Games.Tala.vnz.VnzConstant.handXs[slot];
    this._handY$1 = Games.Tala.vnz.VnzConstant.handYs[slot];
}
Games.Tala.vnz.SlotCard.prototype = {
    _slot$1: 0,
    _handX$1: 0,
    _handY$1: 0,
    _holder$1: null,
    
    loadContent: function Games_Tala_vnz_SlotCard$loadContent() {
        Games.Tala.vnz.SlotCard.callBase(this, 'loadContent');
        var faceDownH = this.get_container().get_contentManager().createImageFromUrl('_Resources/TaLa/img/facedown.png');
        this._holder$1 = new Games.Base.Components.FacedownHolder(Games.Base.Components.CardSuite.instance.get_faceDownImage(), Games.Base.Components.CardSuite.instance.get_faceDownImage(), 5, 5, 15, 15, 10, Games.Tala.vnz.VnzConstant.directions[this._slot$1]);
        this._holder$1.set_size(0);
        this._holder$1.set_visible(true);
        this._holder$1.set_x(this._handX$1);
        this._holder$1.set_y(this._handY$1);
        this.add(this._holder$1);
    },
    
    puzzle: function Games_Tala_vnz_SlotCard$puzzle() {
        this._holder$1.puzzle(9);
    },
    
    attack: function Games_Tala_vnz_SlotCard$attack(count) {
        /// <param name="count" type="Number" integer="true">
        /// </param>
        this._holder$1.set_size(this._holder$1.get_size() - count);
    },
    
    resetParams: function Games_Tala_vnz_SlotCard$resetParams() {
        this._holder$1.set_size(0);
        this._holder$1.set_x(this._handX$1);
        this._holder$1.set_y(this._handY$1);
    },
    
    showCards: function Games_Tala_vnz_SlotCard$showCards(cards) {
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        this._holder$1.set_size(0);
        this._holder$1.flip(cards);
    },
    
    pick: function Games_Tala_vnz_SlotCard$pick(seat) {
        /// <param name="seat" type="Number" integer="true">
        /// </param>
        this._holder$1.set_size(this._holder$1.get_size() + 1);
    },
    
    eat: function Games_Tala_vnz_SlotCard$eat(card) {
        /// <param name="card" type="Number" integer="true">
        /// </param>
        this._holder$1.set_size(this._holder$1.get_size() + 1);
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.vnz.SlotPhom

Games.Tala.vnz.SlotPhom = function Games_Tala_vnz_SlotPhom(slot) {
    /// <param name="slot" type="Number" integer="true">
    /// </param>
    /// <field name="_phoms$1" type="Array" elementType="PhomGroup">
    /// </field>
    /// <field name="_slot$1" type="Number" integer="true">
    /// </field>
    /// <field name="_handX$1" type="Number" integer="true">
    /// </field>
    /// <field name="_handY$1" type="Number" integer="true">
    /// </field>
    /// <field name="__phomClick$1" type="Games.Tala.PhomClick">
    /// </field>
    this._phoms$1 = new Array(3);
    Games.Tala.vnz.SlotPhom.constructBase(this);
    this._slot$1 = slot;
    this._handX$1 = Games.Tala.vnz.VnzConstant.handXs[slot];
    this._handY$1 = Games.Tala.vnz.VnzConstant.handYs[slot];
}
Games.Tala.vnz.SlotPhom.prototype = {
    _slot$1: 0,
    _handX$1: 0,
    _handY$1: 0,
    
    loadContent: function Games_Tala_vnz_SlotPhom$loadContent() {
        Games.Tala.vnz.SlotPhom.callBase(this, 'loadContent');
        for (var i = 0; i < 3; i++) {
            this._phoms$1[i] = new Games.Tala.vnz.PhomGroup(Games.Tala.vnz.VnzConstant.expands[this._slot$1]);
            var phom = this._phoms$1[i];
            phom.set_width(Games.Tala.vnz.VnzConstant.cardWidth * 3);
            phom.set_height(Games.Tala.vnz.VnzConstant.cardHeight);
            phom.seatIndex = this._slot$1;
            phom.pos = i;
            phom.set_x(Games.Tala.vnz.VnzConstant.cardDaHaX[this._slot$1][i]);
            phom.set_y(Games.Tala.vnz.VnzConstant.cardDaHaY[this._slot$1][i]);
            phom.add_click(Delegate.create(this, this._onPhomClick$1));
        }
        var order = Games.Tala.vnz.VnzConstant.orders[this._slot$1];
        for (var i = 0; i < order.length; i++) {
            var tmp = order[i];
            this.add(this._phoms$1[tmp]);
        }
    },
    
    add_phomClick: function Games_Tala_vnz_SlotPhom$add_phomClick(value) {
        /// <param name="value" type="Function" />
        this.__phomClick$1 = Delegate.combine(this.__phomClick$1, value);
    },
    remove_phomClick: function Games_Tala_vnz_SlotPhom$remove_phomClick(value) {
        /// <param name="value" type="Function" />
        this.__phomClick$1 = Delegate.remove(this.__phomClick$1, value);
    },
    
    __phomClick$1: null,
    
    _onPhomClick$1: function Games_Tala_vnz_SlotPhom$_onPhomClick$1(sender, x, y) {
        /// <param name="sender" type="ZeroScript.Core.Games.IComponent">
        /// </param>
        /// <param name="x" type="Number" integer="true">
        /// </param>
        /// <param name="y" type="Number" integer="true">
        /// </param>
        var phom = sender;
        if (this.__phomClick$1 != null) {
            this.__phomClick$1.invoke(phom.phomId, phom.ownerId);
        }
    },
    
    _getNextEmptyPhom$1: function Games_Tala_vnz_SlotPhom$_getNextEmptyPhom$1() {
        /// <returns type="Games.Tala.vnz.PhomGroup"></returns>
        for (var i = 0; i < 3; i++) {
            var p = this._phoms$1[i];
            if (p.eatenCard === -1 && p.get_cards().get_count() === 0) {
                return p;
            }
        }
        return null;
    },
    
    showPhom: function Games_Tala_vnz_SlotPhom$showPhom(cards, phomId, ownerId) {
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        /// <param name="ownerId" type="Number" integer="true">
        /// </param>
        var p = null;
        p = this._getPhomByEatCard$1(cards);
        if (p == null) {
            p = this._getNextEmptyPhom$1();
        }
        p.set_visible(true);
        p.attachCards(new ZeroScript.Core.List(cards), phomId, ownerId, this._handX$1, this._handY$1);
    },
    
    _getPhomByEatCard$1: function Games_Tala_vnz_SlotPhom$_getPhomByEatCard$1(cards) {
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        /// <returns type="Games.Tala.vnz.PhomGroup"></returns>
        var list = new ZeroScript.Core.List(cards);
        for (var i = 0; i < 3; i++) {
            var p = this._phoms$1[i];
            if (list.contains(p.eatenCard)) {
                return p;
            }
        }
        return null;
    },
    
    gui: function Games_Tala_vnz_SlotPhom$gui(cards, fromSeat, phomId) {
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        /// <param name="fromSeat" type="Number" integer="true">
        /// </param>
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        var p = this._getPhomById$1(phomId);
        var x = Games.Tala.vnz.VnzConstant.handXs[fromSeat];
        var y = Games.Tala.vnz.VnzConstant.handYs[fromSeat];
        if (p == null) {
            return;
        }
        p.attachCards(new ZeroScript.Core.List(cards), phomId, p.ownerId, x, y);
    },
    
    eat: function Games_Tala_vnz_SlotPhom$eat(card) {
        /// <param name="card" type="Number" integer="true">
        /// </param>
        var c = Games.Base.Components.CardSuite.instance.get(card);
        var phom = this._getNextEmptyPhom$1();
        phom.set_visible(true);
        phom.eatenCard = card;
        phom.attachCard(card, -1, -1, c.get_x(), c.get_y());
    },
    
    _getPhomById$1: function Games_Tala_vnz_SlotPhom$_getPhomById$1(phomId) {
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        /// <returns type="Games.Tala.vnz.PhomGroup"></returns>
        for (var i = 0; i < 3; i++) {
            var p = this._phoms$1[i];
            if (p.phomId === phomId) {
                return p;
            }
        }
        return null;
    },
    
    resetParams: function Games_Tala_vnz_SlotPhom$resetParams() {
        for (var i = 0; i < 3; i++) {
            this._phoms$1[i].set_visible(false);
            this._phoms$1[i].clearCards();
        }
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.vnz._tableView

Games.Tala.vnz._tableView = function Games_Tala_vnz__tableView() {
    /// <field name="_pick$1" type="Games.Tala.vnz.Picker">
    /// </field>
    /// <field name="_cardCounter$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_groups$1" type="Array" elementType="TalaCardGroup">
    /// </field>
    /// <field name="_templateHaphom$1" type="ZeroScript.Core.Templates.ITemplate">
    /// </field>
    /// <field name="_pickIndicator$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_tableInfo$1" type="Object" domElement="true">
    /// </field>
    /// <field name="__confirmShow$1" type="Callback">
    /// </field>
    /// <field name="__cancelShow$1" type="Callback">
    /// </field>
    /// <field name="__confirmEat$1" type="Callback">
    /// </field>
    this._groups$1 = new Array(Games.Tala.TalaState.maxPlayers);
    Games.Tala.vnz._tableView.constructBase(this);
}
Games.Tala.vnz._tableView.prototype = {
    _pick$1: null,
    _cardCounter$1: null,
    _templateHaphom$1: null,
    _pickIndicator$1: null,
    _tableInfo$1: null,
    
    loadContent: function Games_Tala_vnz__tableView$loadContent() {
        var manager = this.get_container().get_contentManager();
        var cardSuiteImage = manager.createImageFromUrl(Games.Tala.vnz.VnzConstant.cardSuiteUrl);
        var imgBgCounter = manager.createImageFromUrl('_Resources/TaLa/img/card_counter_bg.png');
        var imgFacedown = manager.createImage(cardSuiteImage, 0, 4 * Games.Tala.vnz.VnzConstant.cardHeight, Games.Tala.vnz.VnzConstant.cardWidth, Games.Tala.vnz.VnzConstant.cardHeight);
        this._cardCounter$1 = document.getElementById('card_counter');
        this._pickIndicator$1 = document.getElementById('pick_indicator');
        this._tableInfo$1 = document.getElementById('table_info');
        this._tableInfo$1.innerHTML = Games.Tala.TalaState.current.get_tableInfo();
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            this._groups$1[i] = new Games.Tala.vnz.TalaCardGroup(Games.Tala.vnz.VnzConstant.space);
            this._groups$1[i].set_x(Games.Tala.vnz.VnzConstant.cardDaDanhXs[i]);
            this._groups$1[i].set_y(Games.Tala.vnz.VnzConstant.cardDaDanhYs[i]);
            this.add(this._groups$1[i]);
        }
        this._pick$1 = new Games.Tala.vnz.Picker(imgFacedown, imgBgCounter, this._cardCounter$1);
        this._pick$1.set_x(Games.Tala.vnz.VnzConstant.centerX);
        this._pick$1.set_y(Games.Tala.vnz.VnzConstant.centerY);
        this._pick$1.set_width(Games.Tala.vnz.VnzConstant.cardWidth);
        this._pick$1.set_height(this.get_height());
        this._pick$1.add_click(Delegate.create(this, this._onPickClick$1));
        this.add(this._pick$1);
        EventHelper.attachEvent(this._cardCounter$1, EventHelper.click, Delegate.create(this, this._onDomPickClick$1));
        var d = document.getElementById('template_haphom');
        this._templateHaphom$1 = TemplateEngine.parseTemplate(d.innerHTML);
        var onClose = Delegate.create(this, this.onClose);
        var confirm = Delegate.create(this, this.onConfirm);
        var onBeforeUnload = window.onbeforeunload;
        try {
            window.self.attachEvent('onunload', onClose);
            window.onbeforeunload=Delegate.combine(onBeforeUnload, confirm);
        }
        catch (ex) {
            Debug.writeLine('attach event onbeforeunload error : ' + ex.message);
        }
    },
    
    onClose: function Games_Tala_vnz__tableView$onClose() {
        Games.Base.GameRequest.send('LeaveGame.htm');
    },
    
    onConfirm: function Games_Tala_vnz__tableView$onConfirm() {
        if (Games.Tala.TalaState.current.get_isViewer()) {
            return;
        }
        if (Games.Tala.TalaState.current.get_session().isPlaying) {
            return 'Tho\u00e1t game \u0111\u1ed3ng ngh\u0129a v\u1edbi b\u1ecf cu\u1ed9c. B\u1ea1n mu\u1ed1n tho\u00e1t?';
        }
        else {
            return 'B\u1ea1n ch\u1eafc ch\u1eafn mu\u1ed1n tho\u00e1t?';
        }
    },
    
    _onDomPickClick$1: function Games_Tala_vnz__tableView$_onDomPickClick$1(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        this._sendPick$1();
    },
    
    _onPickClick$1: function Games_Tala_vnz__tableView$_onPickClick$1(sender, x, y) {
        /// <param name="sender" type="ZeroScript.Core.Games.IComponent">
        /// </param>
        /// <param name="x" type="Number" integer="true">
        /// </param>
        /// <param name="y" type="Number" integer="true">
        /// </param>
        this._sendPick$1();
    },
    
    _sendPick$1: function Games_Tala_vnz__tableView$_sendPick$1() {
        Games.Base.GameRequest.send('Pickup.htm');
    },
    
    playerAttack: function Games_Tala_vnz__tableView$playerAttack(seat, card) {
        /// <param name="seat" type="Number" integer="true">
        /// </param>
        /// <param name="card" type="Number" integer="true">
        /// </param>
        var c = Games.Base.Components.CardSuite.instance.get(card);
        var fromX = Games.Tala.vnz.VnzConstant.avatarsX[seat];
        var fromY = Games.Tala.vnz.VnzConstant.avatarsY[seat];
        if (seat === 0 && !Games.Tala.TalaState.current.get_isViewer()) {
            fromX = c.get_x();
            fromY = c.get_y();
        }
        if (this._groups$1[seat] == null) {
            return;
        }
        this._groups$1[seat].attachCard(c, fromX, fromY, false);
    },
    
    get_pickCount: function Games_Tala_vnz__tableView$get_pickCount() {
        /// <value type="Number" integer="true"></value>
        return this._pick$1.get_count();
    },
    set_pickCount: function Games_Tala_vnz__tableView$set_pickCount(value) {
        /// <value type="Number" integer="true"></value>
        this._pick$1.set_count(value);
        return value;
    },
    
    playerPick: function Games_Tala_vnz__tableView$playerPick(seat) {
        /// <param name="seat" type="Number" integer="true">
        /// </param>
        /// <returns type="ZeroScript.Core.Games.IAnimation"></returns>
        this._pick$1.bringToFront();
        var a = this._pick$1.flyTo(Games.Tala.vnz.VnzConstant.avatarsX[seat], Games.Tala.vnz.VnzConstant.avatarsY[seat]);
        a.continueWith(Delegate.create(this, function(c) {
            this._pick$1.hideFly();
        }));
        return a;
    },
    
    resetParams: function Games_Tala_vnz__tableView$resetParams() {
        this.suggestPick(false);
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            this._groups$1[i].get_cards().clear();
        }
        for (var i = 0; i < 52; i++) {
            var card = Games.Base.Components.CardSuite.instance.get(i);
            card.set_x(-100);
            card.set_y(-100);
        }
    },
    
    playerEat: function Games_Tala_vnz__tableView$playerEat(seat, card) {
        /// <param name="seat" type="Number" integer="true">
        /// </param>
        /// <param name="card" type="Number" integer="true">
        /// </param>
        this._groups$1[seat].get_cards().remove(card);
    },
    
    showSuggestPhomDialog: function Games_Tala_vnz__tableView$showSuggestPhomDialog(hasPhom, phoms) {
        /// <param name="hasPhom" type="Boolean">
        /// </param>
        /// <param name="phoms" type="ZeroScript.Core.List">
        /// </param>
        var d = {};
        d['phomCount'] = phoms.get_count();
        d['hasPhom'] = hasPhom;
        var okText = (phoms.get_count() > 0) ? 'H\u1ea1 t\u1ef1 \u0111\u1ed9ng' : 'G\u1eedi';
        var cancelText = (phoms.get_count() > 0) ? ((hasPhom) ? '\u0110\u00e1nh' : 'M\u00f3m') : '\u0110\u00e1nh';
        var dialog = Games.Base.MessageBox.confirm('Th\u00f4ng b\u00e1o', this._templateHaphom$1.generate(d), Delegate.create(this, function() {
            if (this.__confirmShow$1 != null) {
                this.__confirmShow$1.invoke();
            }
            return true;
        }), Delegate.create(this, function() {
            if (this.__cancelShow$1 != null) {
                this.__cancelShow$1.invoke();
            }
        }), okText, cancelText);
        dialog.closeOnBlur = false;
    },
    
    add_confirmShow: function Games_Tala_vnz__tableView$add_confirmShow(value) {
        /// <param name="value" type="Function" />
        this.__confirmShow$1 = Delegate.combine(this.__confirmShow$1, value);
    },
    remove_confirmShow: function Games_Tala_vnz__tableView$remove_confirmShow(value) {
        /// <param name="value" type="Function" />
        this.__confirmShow$1 = Delegate.remove(this.__confirmShow$1, value);
    },
    
    __confirmShow$1: null,
    
    add_cancelShow: function Games_Tala_vnz__tableView$add_cancelShow(value) {
        /// <param name="value" type="Function" />
        this.__cancelShow$1 = Delegate.combine(this.__cancelShow$1, value);
    },
    remove_cancelShow: function Games_Tala_vnz__tableView$remove_cancelShow(value) {
        /// <param name="value" type="Function" />
        this.__cancelShow$1 = Delegate.remove(this.__cancelShow$1, value);
    },
    
    __cancelShow$1: null,
    
    rotateCard: function Games_Tala_vnz__tableView$rotateCard(fromSeat, toSeat) {
        /// <param name="fromSeat" type="Number" integer="true">
        /// </param>
        /// <param name="toSeat" type="Number" integer="true">
        /// </param>
        var fromCards = this._groups$1[fromSeat].get_cards();
        var card = fromCards.get_item(fromCards.get_count() - 1);
        fromCards.remove(card);
        var c = Games.Base.Components.CardSuite.instance.get(card);
        this._groups$1[toSeat].attachCard(c, c.get_x(), c.get_y(), true);
    },
    
    suggestPick: function Games_Tala_vnz__tableView$suggestPick(b) {
        /// <param name="b" type="Boolean">
        /// </param>
        Debug.writeLine('suggest pick ' + b);
        ZeroScript.Core.DomHelper.visible(this._pickIndicator$1, b);
    },
    
    showAnLaoNotify: function Games_Tala_vnz__tableView$showAnLaoNotify() {
        Games.Base.MessageBox.confirm(Global.partner.brandName, 'Qu\u00e2n v\u1eeba \u0103n kh\u00f4ng t\u1ea1o th\u00e0nh ph\u1ecfm<br/>B\u1ea1n c\u00f3 mu\u1ed1n ti\u1ebfp t\u1ee5c?', Delegate.create(this, function() {
            if (this.__confirmEat$1 != null) {
                this.__confirmEat$1.invoke();
            }
            return true;
        }), null, '\u0102n li\u1ec1u', 'Kh\u00f4ng \u0103n');
    },
    
    add_confirmEat: function Games_Tala_vnz__tableView$add_confirmEat(value) {
        /// <param name="value" type="Function" />
        this.__confirmEat$1 = Delegate.combine(this.__confirmEat$1, value);
    },
    remove_confirmEat: function Games_Tala_vnz__tableView$remove_confirmEat(value) {
        /// <param name="value" type="Function" />
        this.__confirmEat$1 = Delegate.remove(this.__confirmEat$1, value);
    },
    
    __confirmEat$1: null
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.vnz.TalaCardGroup

Games.Tala.vnz.TalaCardGroup = function Games_Tala_vnz_TalaCardGroup(space) {
    /// <param name="space" type="Number" integer="true">
    /// </param>
    /// <field name="_attachDuration$1" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="_cards$1" type="ZeroScript.Core.List">
    /// </field>
    /// <field name="_spaceBetweenCards$1" type="Number" integer="true">
    /// </field>
    this._cards$1 = new ZeroScript.Core.List();
    Games.Tala.vnz.TalaCardGroup.constructBase(this);
    this._spaceBetweenCards$1 = space;
}
Games.Tala.vnz.TalaCardGroup.prototype = {
    _spaceBetweenCards$1: 0,
    
    get_cards: function Games_Tala_vnz_TalaCardGroup$get_cards() {
        /// <value type="ZeroScript.Core.List"></value>
        return this._cards$1;
    },
    
    attachCard: function Games_Tala_vnz_TalaCardGroup$attachCard(card, fromX, fromY, isRotate) {
        /// <param name="card" type="Games.Base.Components.Card">
        /// </param>
        /// <param name="fromX" type="Number" integer="true">
        /// </param>
        /// <param name="fromY" type="Number" integer="true">
        /// </param>
        /// <param name="isRotate" type="Boolean">
        /// </param>
        /// <returns type="ZeroScript.Core.Games.IAnimation"></returns>
        this._cards$1.add(card.get_cardId());
        card.bringToFront();
        if (isRotate) {
            card.rotate(240, 360, Games.Tala.vnz.TalaCardGroup._attachDuration$1);
        }
        card.set_x(fromX);
        card.set_y(fromY);
        return card.moveTo(this.get_x() + this._spaceBetweenCards$1 * (this._cards$1.get_count() - 1), this.get_y(), Games.Tala.vnz.TalaCardGroup._attachDuration$1);
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.vnz.VnzActionPart

Games.Tala.vnz.VnzActionPart = function Games_Tala_vnz_VnzActionPart() {
    /// <field name="_view$1" type="Games.Tala.vnz.ActionView">
    /// </field>
    /// <field name="_bus$1" type="ZeroScript.Core.IBus">
    /// </field>
    /// <field name="_attackCard$1" type="Number" integer="true">
    /// </field>
    Games.Tala.vnz.VnzActionPart.constructBase(this);
}
Games.Tala.vnz.VnzActionPart.prototype = {
    _view$1: null,
    _bus$1: null,
    _attackCard$1: 0,
    
    initPart: function Games_Tala_vnz_VnzActionPart$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        this._bus$1 = container.get_bus();
        this._view$1 = new Games.Tala.vnz.ActionView();
        this._view$1.add_attack(Delegate.create(this, this._onAttack$1));
        this._view$1.add_sort(Delegate.create(this, this._onSort$1));
        this._view$1.add_u(Delegate.create(this, this._onU$1));
        this._view$1.add_show(Delegate.create(this, this._onShow$1));
        this._bus$1.subcribe('YourCards', Delegate.create(this, this._onGameStart$1));
        this._bus$1.subcribe('GameEnd', Delegate.create(this, this._onGameEnd$1));
        this._bus$1.subcribe('ClientDevilFishMove', Delegate.create(this, this._onClientMove$1));
        this._bus$1.subcribe('DevilFishMoveResponse', Delegate.create(this, this._onMoveResponse$1));
        this._bus$1.subcribe('ChangeTurn', Delegate.create(this, this._onChangeTurn$1));
        this._bus$1.subcribe('YourTurn', Delegate.create(this, this._onYourTurn$1));
        this._bus$1.subcribe('DevilFishPickResponse', Delegate.create(this, this._onPickResponse$1));
        this._bus$1.subcribe('DevilFishEatResponse', Delegate.create(this, this._onEatResponse$1));
        this._bus$1.subcribe('on.last.turn', Delegate.create(this, this._onLastTurn$1));
    },
    
    _onYourTurn$1: function Games_Tala_vnz_VnzActionPart$_onYourTurn$1(item) {
        /// <param name="item" type="Games.Base.Messages.YourTurn">
        /// </param>
        this._view$1.set_state(Games.Tala.ActionState.yourTurn);
    },
    
    _onEatResponse$1: function Games_Tala_vnz_VnzActionPart$_onEatResponse$1(item) {
        /// <param name="item" type="Games.Tala.DevilFishEatResponse">
        /// </param>
        this._view$1.set_state(Games.Tala.ActionState.eat);
    },
    
    _onPickResponse$1: function Games_Tala_vnz_VnzActionPart$_onPickResponse$1(item) {
        /// <param name="item" type="Games.Tala.DevilFishPickResponse">
        /// </param>
        this._view$1.set_state(Games.Tala.ActionState.pick);
    },
    
    _onChangeTurn$1: function Games_Tala_vnz_VnzActionPart$_onChangeTurn$1(m) {
        /// <param name="m" type="Games.Base.Messages.ChangeTurn">
        /// </param>
        if (m.userId !== Global.get_user().id) {
            this._view$1.set_state(Games.Tala.ActionState.someOneTurn);
        }
    },
    
    _onGameStart$1: function Games_Tala_vnz_VnzActionPart$_onGameStart$1(item) {
        /// <param name="item" type="Object">
        /// </param>
        this._view$1.set_state(Games.Tala.ActionState.start);
    },
    
    _onLastTurn$1: function Games_Tala_vnz_VnzActionPart$_onLastTurn$1(d) {
        /// <param name="d" type="Object">
        /// </param>
        this._view$1.set_state(Games.Tala.ActionState.lastTurn);
    },
    
    _onClientMove$1: function Games_Tala_vnz_VnzActionPart$_onClientMove$1(m) {
        /// <param name="m" type="Games.Tala.ClientDevilFishMove">
        /// </param>
        this._publishAttackAction$1(m.senderId, m.card);
    },
    
    _onMoveResponse$1: function Games_Tala_vnz_VnzActionPart$_onMoveResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishMoveResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            Games.Base.MessageBox.notify('Kh\u00f4ng \u0111\u00e1nh \u0111\u01b0\u1ee3c!');
        }
        else {
            var userId = Global.get_user().id;
            Games.Base.Components.CardInHand.instance.attacking = false;
            this._publishAttackAction$1(userId, m.card);
        }
    },
    
    _publishAttackAction$1: function Games_Tala_vnz_VnzActionPart$_publishAttackAction$1(userId, card) {
        /// <param name="userId" type="Number" integer="true">
        /// </param>
        /// <param name="card" type="Number" integer="true">
        /// </param>
        this._bus$1.publish('player.attack', new Games.Tala.PlayerAttack(userId, card));
    },
    
    _onAttack$1: function Games_Tala_vnz_VnzActionPart$_onAttack$1() {
        if (!Games.Tala.TalaState.current.get_isYourTurn()) {
            return;
        }
        var cards = Games.Base.Components.CardInHand.instance.getSelectedCards();
        if (cards.get_count() <= 0) {
            return;
        }
        this._attackCard$1 = cards.get_item(0);
        if (Games.Tala.TalaState.current.isLastTurn) {
            this._bus$1.publish('player.last.attack', new Games.Tala.PlayerAttack(Global.get_user().id, this._attackCard$1));
        }
        else {
            Games.Base.Components.CardInHand.instance.attacking = true;
            Games.Base.GameRequest.send('Move.htm', 'cards', [ this._attackCard$1 ]);
        }
        this._attackCard$1 = -1;
    },
    
    _onShow$1: function Games_Tala_vnz_VnzActionPart$_onShow$1() {
        if (!Games.Tala.TalaState.current.get_isYourTurn()) {
            return;
        }
        var cards = Games.Base.Components.CardInHand.instance.getSelectedCards();
        if (cards.get_count() > 0) {
            var arr = cards.toArray();
            Games.Base.GameRequest.send('ShowPhom.htm', 'cards', arr);
        }
        else {
            this._bus$1.publish('player.show.phom', null);
        }
    },
    
    _onU$1: function Games_Tala_vnz_VnzActionPart$_onU$1() {
        if (!Games.Tala.TalaState.current.get_isYourTurn()) {
            return;
        }
        Games.Base.GameRequest.send('U.htm');
    },
    
    _onSort$1: function Games_Tala_vnz_VnzActionPart$_onSort$1() {
        Games.Base.Components.CardInHand.instance.sort();
    },
    
    _onGameEnd$1: function Games_Tala_vnz_VnzActionPart$_onGameEnd$1(m) {
        /// <param name="m" type="Games.Base.Messages.GameEnd">
        /// </param>
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.vnz.VnzActivityPart

Games.Tala.vnz.VnzActivityPart = function Games_Tala_vnz_VnzActivityPart() {
    /// <field name="_element$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_transMsg$1" type="Array" elementType="String">
    /// </field>
    Games.Tala.vnz.VnzActivityPart.constructBase(this);
}
Games.Tala.vnz.VnzActivityPart.prototype = {
    _element$1: null,
    _transMsg$1: null,
    
    initPart: function Games_Tala_vnz_VnzActivityPart$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        var bus = container.get_bus();
        bus.subcribe('game.activity', Delegate.create(this, this._onGameActivity$1));
        bus.subcribe('NewTransaction', Delegate.create(this, this._onNewTransaction$1));
        this._element$1 = document.getElementById('chat_content');
        this._initMessages$1();
    },
    
    _initMessages$1: function Games_Tala_vnz_VnzActivityPart$_initMessages$1() {
        this._transMsg$1 = new Array(10);
        this._transMsg$1[Games.Tala.DevilFishTransactionReason.anChot] = '\u0103n ch\u1ed1t';
        this._transMsg$1[Games.Tala.DevilFishTransactionReason.denLang] = '\u0111\u1ec1n l\u00e0ng';
        this._transMsg$1[Games.Tala.DevilFishTransactionReason.moms] = 'm\u00f3m!';
    },
    
    _onNewTransaction$1: function Games_Tala_vnz_VnzActivityPart$_onNewTransaction$1(m) {
        /// <param name="m" type="Games.Tala.NewTransaction">
        /// </param>
        var rawUsers = Games.Tala.TalaState.current.get_session().rawUsers;
        if (rawUsers[m.fromSlot] == null || rawUsers[m.toSlot] == null) {
            return;
        }
        var text = this._activityToText$1(rawUsers[m.fromSlot].firstName, rawUsers[m.toSlot].firstName, m.reason, m.amount);
        this._display$1(text, true);
    },
    
    _activityToText$1: function Games_Tala_vnz_VnzActivityPart$_activityToText$1(from, to, reason, amount) {
        /// <param name="from" type="String">
        /// </param>
        /// <param name="to" type="String">
        /// </param>
        /// <param name="reason" type="Number" integer="true">
        /// </param>
        /// <param name="amount" type="Number" integer="true">
        /// </param>
        /// <returns type="String"></returns>
        var message = this._transMsg$1[reason];
        if (isNullOrUndefined(message) || message === '') {
            return String.Empty;
        }
        if (reason === Games.Tala.DevilFishTransactionReason.gameEnd) {
            return String.Empty;
        }
        if (reason === Games.Tala.DevilFishTransactionReason.anChot) {
            return String.format('{0} {1} {2}, {3}<br>', to, message, from, Format.currency(amount));
        }
        return String.format('{0} {1}<br>', from, message);
    },
    
    _onGameActivity$1: function Games_Tala_vnz_VnzActivityPart$_onGameActivity$1(text) {
        /// <param name="text" type="String">
        /// </param>
        var dom = this._display$1(text, false);
        window.toggleGameResult(dom);;
    },
    
    _display$1: function Games_Tala_vnz_VnzActivityPart$_display$1(text, isFeed) {
        /// <param name="text" type="String">
        /// </param>
        /// <param name="isFeed" type="Boolean">
        /// </param>
        /// <returns type="Object" domElement="true"></returns>
        var d = document.createElement('p');
        if (text === String.Empty) {
            return d;
        }
        if (isFeed) {
            d.className = 'txt_special';
        }
        ZeroScript.Core.JQuery.JQueryHelper.select(d).html(text);
        this._element$1.appendChild(d);
        this._element$1.scrollTop = this._element$1.scrollHeight;
        return d;
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.vnz.VnzBubblePart

Games.Tala.vnz.VnzBubblePart = function Games_Tala_vnz_VnzBubblePart() {
    /// <field name="_maxPlayers$1" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="_bubbles$1" type="Array" elementType="BubbleView">
    /// </field>
    /// <field name="_slots$1" type="Array" elementType="Number" elementInteger="true">
    /// </field>
    this._bubbles$1 = new Array(Games.Tala.vnz.VnzBubblePart._maxPlayers$1);
    this._slots$1 = new Array(Games.Tala.vnz.VnzBubblePart._maxPlayers$1);
    Games.Tala.vnz.VnzBubblePart.constructBase(this);
    for (var i = 0; i < Games.Tala.vnz.VnzBubblePart._maxPlayers$1; i++) {
        var dom = document.getElementById('bubble_' + i);
        if (dom == null) {
            break;
        }
        this._bubbles$1[i] = new Games.Tala.vnz.BubbleView(dom);
    }
}
Games.Tala.vnz.VnzBubblePart.prototype = {
    
    initPart: function Games_Tala_vnz_VnzBubblePart$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        var b = container.get_bus();
        b.subcribe('ClientChatMessage', Delegate.create(this, this._onChatReceive$1));
    },
    
    _onChatReceive$1: function Games_Tala_vnz_VnzBubblePart$_onChatReceive$1(m) {
        /// <param name="m" type="Games.Base.Messages.ChatMessage">
        /// </param>
        var seat = Games.Tala.TalaState.current.getSeat(m.senderId);
        if (seat < 0 || Games.Base.Data.User.isBlock(m.senderId)) {
            return;
        }
        this._bubbles$1[seat].set_text(m.text);
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.vnz.VnzConstant

Games.Tala.vnz.VnzConstant = function Games_Tala_vnz_VnzConstant() {
    /// <field name="cardSuiteUrl" type="String" static="true">
    /// </field>
    /// <field name="space" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="centerX" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="centerY" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="directions" type="Array" elementType="ExpandDirect" static="true">
    /// </field>
    /// <field name="cardWidth" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="cardHeight" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="viewWidth" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="viewHeight" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="groupPhomX" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="groupPhomY" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="slot1PhomX" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="slot1PhomY" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="cardDaDanhXs" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="cardDaDanhYs" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="avatarsX" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="avatarsY" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="cardInHandX" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="cardInHandY" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="handXs" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="handYs" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="cardDaHaX" type="Array" elementType="Array" static="true">
    /// </field>
    /// <field name="cardDaHaY" type="Array" elementType="Array" static="true">
    /// </field>
    /// <field name="expands" type="Array" elementType="ExpandDirect" static="true">
    /// </field>
    /// <field name="orders" type="Array" elementType="Array" static="true">
    /// </field>
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.vnz.VnzGameMenu

Games.Tala.vnz.VnzGameMenu = function Games_Tala_vnz_VnzGameMenu() {
    /// <field name="_startBtn$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_quitBtn$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_joinBtn$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_standUpBtn$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_themeBtn$1" type="Object" domElement="true">
    /// </field>
    /// <field name="_joinPrivateSessionTemplate$1" type="ZeroScript.Core.Templates.ITemplate">
    /// </field>
    /// <field name="_container$1" type="ZeroScript.Core.Parts.IPartContainer">
    /// </field>
    /// <field name="_bus$1" type="ZeroScript.Core.IBus">
    /// </field>
    Games.Tala.vnz.VnzGameMenu.constructBase(this);
}
Games.Tala.vnz.VnzGameMenu.prototype = {
    _startBtn$1: null,
    _quitBtn$1: null,
    _joinBtn$1: null,
    _standUpBtn$1: null,
    _themeBtn$1: null,
    _joinPrivateSessionTemplate$1: null,
    _container$1: null,
    _bus$1: null,
    
    initPart: function Games_Tala_vnz_VnzGameMenu$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        this._container$1 = container;
        this._joinPrivateSessionTemplate$1 = TemplateEngine.parseTemplate(document.getElementById('tmp_join_private_session').innerHTML);
        this._startBtn$1 = document.getElementById('start0');
        this._quitBtn$1 = document.getElementById('button_quit');
        this._joinBtn$1 = document.getElementById('join_btn');
        this._standUpBtn$1 = document.getElementById('button_standup');
        this._themeBtn$1 = document.getElementById('button_share');
        ZeroScript.Core.DomHelper.visible(this._themeBtn$1, false);
        EventHelper.attachEvent(this._startBtn$1, EventHelper.click, Delegate.create(this, this._onStartClick$1));
        EventHelper.attachEvent(this._quitBtn$1, EventHelper.click, Delegate.create(this, this._onQuitClick$1));
        EventHelper.attachEvent(this._joinBtn$1, EventHelper.click, Delegate.create(this, this._onJoinClick$1));
        EventHelper.attachEvent(this._standUpBtn$1, EventHelper.click, Delegate.create(this, this._onStandUpClick$1));
        this._bus$1 = this._container$1.get_bus();
        this._bus$1.subcribe('ClientStandUp', Delegate.create(this, this._onStandUp$1));
        this._bus$1.subcribe('JoinSessionResponse', Delegate.create(this, this._onJoinResponse$1));
        this._bus$1.subcribe('YourCards', Delegate.create(this, this._onGameStart$1));
        this._bus$1.subcribe('GameEnd', Delegate.create(this, this._onGameEnd$1));
        this._bus$1.subcribe('ChangeHost', Delegate.create(this, this._onChangeHost$1));
        this._bus$1.subcribe('PlayerJoinOpenSession', Delegate.create(this, this._onPlayerJoin$1));
        this._bus$1.subcribe('ClientLeaveOpenSession', Delegate.create(this, this._onPlayerLeaveOpenSession$1));
    },
    
    _onPlayerLeaveOpenSession$1: function Games_Tala_vnz_VnzGameMenu$_onPlayerLeaveOpenSession$1(item) {
        /// <param name="item" type="Games.Base.Messages.ClientLeaveOpenSession">
        /// </param>
        this._maybeDisplayJoinBtn$1();
    },
    
    _onPlayerJoin$1: function Games_Tala_vnz_VnzGameMenu$_onPlayerJoin$1(item) {
        /// <param name="item" type="Games.Base.Messages.PlayerJoinOpenSession">
        /// </param>
        this._maybeDisplayJoinBtn$1();
    },
    
    _onChangeHost$1: function Games_Tala_vnz_VnzGameMenu$_onChangeHost$1(item) {
        /// <param name="item" type="Games.Base.Messages.ChangeHost">
        /// </param>
        this._maybeDisplayStart$1();
    },
    
    _onGameEnd$1: function Games_Tala_vnz_VnzGameMenu$_onGameEnd$1(m) {
        /// <param name="m" type="Games.Base.Messages.GameEnd">
        /// </param>
        this._maybeDisplayJoinBtn$1();
        this._maybeDisplayStart$1();
        this._maybeDisplayStandUpBtn$1();
    },
    
    _maybeDisplayStart$1: function Games_Tala_vnz_VnzGameMenu$_maybeDisplayStart$1() {
        if (Games.Tala.TalaState.current.host === Global.get_user().id && Games.Tala.TalaState.current.get_hasOpenSlot() && !Games.Tala.TalaState.current.get_isPlaying()) {
            window.setTimeout(Delegate.create(this, function() {
                if (Games.Tala.TalaState.current.get_isPlaying()) {
                    return;
                }
                ZeroScript.Core.DomHelper.visible(this._startBtn$1, true);
            }), 7000);
        }
    },
    
    _onGameStart$1: function Games_Tala_vnz_VnzGameMenu$_onGameStart$1(obj) {
        /// <param name="obj" type="Games.Tala.YourCards">
        /// </param>
        this._maybeDisplayJoinBtn$1();
        ZeroScript.Core.DomHelper.visible(this._startBtn$1, false);
        this._maybeDisplayStandUpBtn$1();
    },
    
    _onJoinResponse$1: function Games_Tala_vnz_VnzGameMenu$_onJoinResponse$1(m) {
        /// <param name="m" type="Games.Base.Messages.JoinSessionRespond">
        /// </param>
        if (GameError.isOkie(m.error)) {
            ZeroScript.Core.DomHelper.visible(this._joinBtn$1, false);
            ZeroScript.Core.DomHelper.visible(this._startBtn$1, false);
            this._maybeDisplayStandUpBtn$1();
        }
    },
    
    _onStandUp$1: function Games_Tala_vnz_VnzGameMenu$_onStandUp$1(obj) {
        /// <param name="obj" type="Object">
        /// </param>
        this._maybeDisplayJoinBtn$1();
        this._maybeDisplayStart$1();
        this._maybeDisplayStandUpBtn$1();
    },
    
    _onStandUpClick$1: function Games_Tala_vnz_VnzGameMenu$_onStandUpClick$1(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        Games.Base.GameRequest.send('StandUp.htm');
    },
    
    _onJoinClick$1: function Games_Tala_vnz_VnzGameMenu$_onJoinClick$1(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        var session = Games.Tala.TalaState.current.get_session();
        if (session.isPrivate) {
            Games.Base.MessageBox.form('Th\u00f4ng b\u00e1o', this._joinPrivateSessionTemplate$1.generate(session), Delegate.create(this, function(form) {
                if (!session.isPlaying) {
                    var password = form.get_item('password');
                    Games.Base.GameRequest.send('ViewerJoinSession.htm', 'id', session.id, 'password', password);
                }
                form.close.invoke();
            }), null);
        }
        else {
            Games.Base.GameRequest.send('ViewerJoinSession.htm', 'id', session.id, 'password', String.Empty);
        }
    },
    
    _onQuitClick$1: function Games_Tala_vnz_VnzGameMenu$_onQuitClick$1(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        this._bus$1.publish('navigator.backToSession', new Games.Parts.Common.NavigatorParams(Global.get_gameId(), Global.get_channel().id));
    },
    
    _onStartClick$1: function Games_Tala_vnz_VnzGameMenu$_onStartClick$1(args) {
        /// <param name="args" type="ZeroScript.Core.DOMEventArgs">
        /// </param>
        Games.Base.GameRequest.send('StartGame.htm');
    },
    
    active: function Games_Tala_vnz_VnzGameMenu$active() {
        this._maybeDisplayJoinBtn$1();
        this._maybeDisplayStart$1();
        this._maybeDisplayStandUpBtn$1();
    },
    
    _maybeDisplayJoinBtn$1: function Games_Tala_vnz_VnzGameMenu$_maybeDisplayJoinBtn$1() {
        var visible = Games.Tala.TalaState.current.get_hasOpenSlot() && Games.Tala.TalaState.current.get_isViewer() && !Games.Tala.TalaState.current.isPending(Global.get_user().id);
        ZeroScript.Core.DomHelper.visible(this._joinBtn$1, visible);
    },
    
    _maybeDisplayStandUpBtn$1: function Games_Tala_vnz_VnzGameMenu$_maybeDisplayStandUpBtn$1() {
        var visible = !Games.Tala.TalaState.current.get_isViewer();
        ZeroScript.Core.DomHelper.visible(this._standUpBtn$1, visible);
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.vnz.VnzPlayerPart

Games.Tala.vnz.VnzPlayerPart = function Games_Tala_vnz_VnzPlayerPart() {
    /// <field name="_slots$1" type="Array" elementType="PlayerView">
    /// </field>
    /// <field name="_bus$1" type="ZeroScript.Core.IBus">
    /// </field>
    Games.Tala.vnz.VnzPlayerPart.constructBase(this);
}
Games.Tala.vnz.VnzPlayerPart.prototype = {
    _slots$1: null,
    _bus$1: null,
    
    get_state: function Games_Tala_vnz_VnzPlayerPart$get_state() {
        /// <value type="Games.Tala.TalaState"></value>
        return Games.Tala.TalaState.current;
    },
    
    initPart: function Games_Tala_vnz_VnzPlayerPart$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        this._bus$1 = container.get_bus();
        this._bus$1.subcribe('PlayerJoinOpenSession', Delegate.create(this, this._onPlayerJoin$1));
        this._bus$1.subcribe('JoinSessionResponse', Delegate.create(this, this._onJoinResponse$1));
        this._bus$1.subcribe('YourCards', Delegate.create(this, this._onGameStart$1));
        this._bus$1.subcribe('GameEnd', Delegate.create(this, this._onGameEnd$1));
        this._bus$1.subcribe('DevilFishShowResponse', Delegate.create(this, this._onShowResponse$1));
        this._bus$1.subcribe('slot.updated', Delegate.create(this, this._onSlotUpdated$1));
    },
    
    _onGameStart$1: function Games_Tala_vnz_VnzPlayerPart$_onGameStart$1(item) {
        /// <param name="item" type="Games.Tala.YourCards">
        /// </param>
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            this._slots$1[i].set_showLevel(true);
        }
    },
    
    _onShowResponse$1: function Games_Tala_vnz_VnzPlayerPart$_onShowResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishShowResponse">
        /// </param>
        var seat = Games.Tala.TalaState.current.getSeat(m.senderId);
        if (seat === 1) {
            this._slots$1[seat + 1].set_showLevel(false);
        }
    },
    
    active: function Games_Tala_vnz_VnzPlayerPart$active() {
    },
    
    inActive: function Games_Tala_vnz_VnzPlayerPart$inActive() {
    },
    
    _onGameEnd$1: function Games_Tala_vnz_VnzPlayerPart$_onGameEnd$1(m) {
        /// <param name="m" type="Games.Base.Messages.GameEnd">
        /// </param>
    },
    
    _onJoinResponse$1: function Games_Tala_vnz_VnzPlayerPart$_onJoinResponse$1(m) {
        /// <param name="m" type="Games.Base.Messages.JoinSessionRespond">
        /// </param>
        if (GameError.isOkie(m.error)) {
            this._drawNewPlayer$1();
        }
    },
    
    _onPlayerJoin$1: function Games_Tala_vnz_VnzPlayerPart$_onPlayerJoin$1(m) {
        /// <param name="m" type="Games.Base.Messages.PlayerJoinOpenSession">
        /// </param>
        this._drawNewPlayer$1();
    },
    
    _drawNewPlayer$1: function Games_Tala_vnz_VnzPlayerPart$_drawNewPlayer$1() {
        if (Games.Tala.TalaState.current.get_isPlaying()) {
            var users = Games.Tala.TalaState.current.get_pendingJoin();
            var start = (users.get_count() === 1) ? 0 : 1;
            for (var i = start; i < users.get_count(); i++) {
                var u = users.get_item(i);
                for (var j = 0; j < this._slots$1.length; j++) {
                    if (this._slots$1[j].get_user() == null) {
                        this._slots$1[j].set_user(u);
                        this._slots$1[j].show();
                        this._slots$1[j].showHost(false);
                        break;
                    }
                }
            }
        }
    },
    
    init: function Games_Tala_vnz_VnzPlayerPart$init(container) {
        /// <param name="container" type="ZeroScript.Core.Games.IComponentContainer">
        /// </param>
        Games.Tala.vnz.VnzPlayerPart.callBase(this, 'init', [ container ]);
        this._slots$1 = new Array(Games.Tala.TalaState.maxPlayers);
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            var slot = new Games.Tala.vnz.PlayerView(i, this._bus$1);
            this._slots$1[i] = slot;
        }
    },
    
    run: function Games_Tala_vnz_VnzPlayerPart$run() {
        this._updateSlots$1();
    },
    
    get_component: function Games_Tala_vnz_VnzPlayerPart$get_component() {
        /// <value type="ZeroScript.Core.Games.IComponent"></value>
        return this;
    },
    
    _onSlotUpdated$1: function Games_Tala_vnz_VnzPlayerPart$_onSlotUpdated$1(text) {
        /// <param name="text" type="String">
        /// </param>
        this._updateSlots$1();
    },
    
    _updateSlots$1: function Games_Tala_vnz_VnzPlayerPart$_updateSlots$1() {
        for (var i = 0; i < this._slots$1.length; i++) {
            this._slots$1[i].set_user(null);
        }
        for (var i = 0; i < this.get_state().get_session().users.length; i++) {
            var u = this.get_state().get_session().users[i];
            if (isNullOrUndefined(u)) {
                continue;
            }
            var seat = this.get_state().getSeat(u.id);
            var playerSlot = this._slots$1[seat];
            playerSlot.set_user(u);
            playerSlot.show();
            playerSlot.showHost(this.get_state().host === u.id);
        }
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.vnz.VnzResultPart

Games.Tala.vnz.VnzResultPart = function Games_Tala_vnz_VnzResultPart() {
    /// <field name="_result$2" type="Object" domElement="true">
    /// </field>
    /// <field name="_bus$2" type="ZeroScript.Core.IBus">
    /// </field>
    /// <field name="u" type="String" static="true">
    /// </field>
    /// <field name="uKhan" type="String" static="true">
    /// </field>
    /// <field name="mom" type="String" static="true">
    /// </field>
    /// <field name="uDen" type="String" static="true">
    /// </field>
    /// <field name="denLang" type="String" static="true">
    /// </field>
    /// <field name="leaveGame" type="String" static="true">
    /// </field>
    /// <field name="empty" type="String" static="true">
    /// </field>
    /// <field name="_resultTexts$2" type="Object" static="true">
    /// </field>
    Games.Tala.vnz.VnzResultPart.constructBase(this);
}
Games.Tala.vnz.VnzResultPart.prototype = {
    _result$2: null,
    _bus$2: null,
    
    initPart: function Games_Tala_vnz_VnzResultPart$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        this._result$2 = ZeroScript.Core.JQuery.JQueryHelper.select('.bangketqua')[0];
        this._bus$2 = container.get_bus();
        this._bus$2.subcribe('GameEnd', Delegate.create(this, this._onGameEnd$2));
    },
    
    _onGameEnd$2: function Games_Tala_vnz_VnzResultPart$_onGameEnd$2(m) {
        /// <param name="m" type="Games.Base.Messages.GameEnd">
        /// </param>
        var r = m.result;
        var result = this._normalizeGameResult$2(r);
        var d = {};
        d['data'] = result.toArray();
        var tmp = TemplateEngine.parseTemplate(document.getElementById('template_endGameActivity').innerHTML);
        var text = tmp.generate(d);
        this.appendResult(text);
    },
    
    _normalizeGameResult$2: function Games_Tala_vnz_VnzResultPart$_normalizeGameResult$2(result) {
        /// <param name="result" type="Games.Base.Messages.BaseGameResult">
        /// </param>
        /// <returns type="ZeroScript.Core.List"></returns>
        var r = result;
        var list = new ZeroScript.Core.List();
        for (var rank = 0; rank < r.users.length; rank++) {
            var slot = r.users[rank];
            var u = Games.Tala.TalaState.current.get_session().rawUsers[slot];
            if (isNullOrUndefined(u)) {
                continue;
            }
            if (!u.isPlaying) {
                continue;
            }
            var a = new Games.Base.Messages.UserResult();
            a.user = u;
            a.exp = r.experiences[rank] + 'exp';
            a.money = r.money[rank];
            a.reason = this._resultToText$2(r.finalUserScores[rank]);
            list.add(a);
        }
        return list;
    },
    
    _resultToText$2: function Games_Tala_vnz_VnzResultPart$_resultToText$2(key) {
        /// <param name="key" type="String">
        /// </param>
        /// <returns type="String"></returns>
        if (!isNaN(key)) {
            return key + ' \u0111i\u1ec3m';
        }
        if (Object.keyExists(Games.Tala.vnz.VnzResultPart._resultTexts$2, key)) {
            return Games.Tala.vnz.VnzResultPart._resultTexts$2[key];
        }
        return key;
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.vnz.VnzSlotPart

Games.Tala.vnz.VnzSlotPart = function Games_Tala_vnz_VnzSlotPart() {
    /// <field name="_slots$1" type="Array" elementType="SlotCard">
    /// </field>
    /// <field name="_cardInHand$1" type="Games.Base.Components.CardInHand">
    /// </field>
    /// <field name="_bus$1" type="ZeroScript.Core.IBus">
    /// </field>
    this._slots$1 = new Array(Games.Tala.TalaState.maxPlayers);
    Games.Tala.vnz.VnzSlotPart.constructBase(this);
}
Games.Tala.vnz.VnzSlotPart.prototype = {
    _cardInHand$1: null,
    _bus$1: null,
    
    initPart: function Games_Tala_vnz_VnzSlotPart$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        this._bus$1 = container.get_bus();
        this._bus$1.subcribe('YourCards', Delegate.create(this, this._onGameStart$1));
        this._bus$1.subcribe('GameEnd', Delegate.create(this, this._onGameEnd$1));
        this._bus$1.subcribe('DevilFishPickResponse', Delegate.create(this, this._onPickResponse$1));
        this._bus$1.subcribe('DevilFishEatResponse', Delegate.create(this, this._onEatResponse$1));
        this._bus$1.subcribe('DevilFishShowResponse', Delegate.create(this, this._onShowResponse$1));
        this._bus$1.subcribe('DevilFishLiveOnResponse', Delegate.create(this, this._onGuiResponse$1));
        this._bus$1.subcribe('player.attack', Delegate.create(this, this._onPlayerAttack$1));
        this._bus$1.subcribe('player.pick', Delegate.create(this, this._onPlayerPick$1));
        this._bus$1.subcribe('on.last.turn', Delegate.create(this, this._onLastTurn$1));
        this._bus$1.subcribe('player.leave.session', Delegate.create(this, this._onPlayerLeave$1));
    },
    
    _onPlayerLeave$1: function Games_Tala_vnz_VnzSlotPart$_onPlayerLeave$1(userId) {
        /// <param name="userId" type="Number" integer="true">
        /// </param>
        if (userId === Global.get_user().id) {
            return;
        }
        var seat = Games.Tala.TalaState.current.getSeat(userId);
        this._slots$1[seat].resetParams();
    },
    
    _onLastTurn$1: function Games_Tala_vnz_VnzSlotPart$_onLastTurn$1(d) {
        /// <param name="d" type="Object">
        /// </param>
        this._cardInHand$1.multiSelect = true;
    },
    
    _onGuiResponse$1: function Games_Tala_vnz_VnzSlotPart$_onGuiResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishLiveOnResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            Games.Base.MessageBox.notify('Kh\u00f4ng g\u1eedi \u0111\u01b0\u1ee3c b\u00e0i!');
            return;
        }
        this._bus$1.publish('ext.player.gui', null);
        var seat = Games.Tala.TalaState.current.getSeat(m.senderId);
        if (seat === 0) {
            this._removeCardsInHand$1(m.cards);
        }
        else {
            this._slots$1[seat].attack(m.cards.length);
        }
    },
    
    _onShowResponse$1: function Games_Tala_vnz_VnzSlotPart$_onShowResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishShowResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            Games.Base.MessageBox.notify('Kh\u00f4ng h\u1ea1 \u0111\u01b0\u1ee3c b\u00e0i!');
            return;
        }
        this._bus$1.publish('ext.player.ha', null);
        var seat = Games.Tala.TalaState.current.getSeat(m.senderId);
        if (seat === 0) {
            var cards = m.cards;
            this._removeCardsInHand$1(cards);
        }
        else {
            this._slots$1[seat].attack(m.cards.length);
        }
    },
    
    _removeCardsInHand$1: function Games_Tala_vnz_VnzSlotPart$_removeCardsInHand$1(cards) {
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        var list = this._cardInHand$1.get_cards();
        for (var i = 0; i < cards.length; i++) {
            list.remove(cards[i]);
        }
        this._cardInHand$1.quickResetCards();
    },
    
    _onEatResponse$1: function Games_Tala_vnz_VnzSlotPart$_onEatResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishEatResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            Games.Base.MessageBox.notify('Kh\u00f4ng \u0103n \u0111\u01b0\u1ee3c!');
            return;
        }
        var music = (m.anChot) ? 'ext.player.anchot' : 'ext.player.an';
        this._bus$1.publish(music, null);
        var seat = Games.Tala.TalaState.current.getSeat(m.senderId);
        if (seat === 0 || m.senderId === 0) {
            var card = Games.Base.Components.CardSuite.instance.get(m.card);
            this._addCardToHand$1(card, card.get_x(), card.get_y()).continueWith(Delegate.create(this, function(c) {
                card.set_marked((Games.Tala.TalaState.current.get_isViewer()) ? false : true);
            }));
        }
        else {
            this._slots$1[seat].eat(m.card);
        }
    },
    
    _onPlayerPick$1: function Games_Tala_vnz_VnzSlotPart$_onPlayerPick$1(d) {
        /// <param name="d" type="Games.Tala.PlayerPick">
        /// </param>
        var seat = Games.Tala.TalaState.current.getSeat(d.userId);
        try {
            if (seat < 0) {
                seat = Games.Tala.TalaState.current.getRawSeat(d.userId);
            }
            this._slots$1[seat].pick(seat);
        }
        catch ($e1) {
            Debug.writeLine('exception @SlotPart.OnPlayerPick: seat = ' + seat + ' userId: ' + d.userId);
        }
    },
    
    _onPickResponse$1: function Games_Tala_vnz_VnzSlotPart$_onPickResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishPickResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            return;
        }
        var card = Games.Base.Components.CardSuite.instance.get(m.card);
        this._addCardToHand$1(card, Games.Tala.vnz.VnzConstant.centerX, Games.Tala.vnz.VnzConstant.centerY);
    },
    
    _addCardToHand$1: function Games_Tala_vnz_VnzSlotPart$_addCardToHand$1(card, fromX, fromY) {
        /// <param name="card" type="Games.Base.Components.Card">
        /// </param>
        /// <param name="fromX" type="Number" integer="true">
        /// </param>
        /// <param name="fromY" type="Number" integer="true">
        /// </param>
        /// <returns type="ZeroScript.Core.Games.IAnimation"></returns>
        var cards = this._cardInHand$1.get_cards();
        cards.add(card.get_cardId());
        var x = (cards.get_count() - 1) * Games.Tala.vnz.VnzConstant.space + this._cardInHand$1.handX;
        var y = this._cardInHand$1.handY;
        card.bringToFront();
        return card.move(fromX, fromY, x, y, 500);
    },
    
    active: function Games_Tala_vnz_VnzSlotPart$active() {
        this._cardInHand$1.initCardEvents();
    },
    
    inActive: function Games_Tala_vnz_VnzSlotPart$inActive() {
    },
    
    _onGameEnd$1: function Games_Tala_vnz_VnzSlotPart$_onGameEnd$1(m) {
        /// <param name="m" type="Games.Base.Messages.GameEnd">
        /// </param>
        var r = m.result;
        this._flipCardInHand$1(r.users[0], r.a);
        this._flipCardInHand$1(r.users[1], r.b);
        this._flipCardInHand$1(r.users[2], r.c);
        this._flipCardInHand$1(r.users[3], r.d);
    },
    
    _flipCardInHand$1: function Games_Tala_vnz_VnzSlotPart$_flipCardInHand$1(playIndex, cards) {
        /// <param name="playIndex" type="Number" integer="true">
        /// </param>
        /// <param name="cards" type="Array" elementType="Number" elementInteger="true">
        /// </param>
        if (Games.Tala.TalaState.current.get_session().users[playIndex] == null) {
            return;
        }
        var seat = Games.Tala.TalaState.current.toSeat(playIndex);
        if (seat < 0) {
            return;
        }
        if (seat === 0 && !Games.Tala.TalaState.current.get_isViewer()) {
            return;
        }
        this._slots$1[seat].showCards(cards);
    },
    
    _onPlayerAttack$1: function Games_Tala_vnz_VnzSlotPart$_onPlayerAttack$1(d) {
        /// <param name="d" type="Games.Tala.PlayerAttack">
        /// </param>
        var seat = Games.Tala.TalaState.current.getSeat(d.userId);
        if (seat < 0) {
            return;
        }
        this._playerAttack$1(seat, d.card);
        this._bus$1.publish('ext.throw.card', null);
    },
    
    _playerAttack$1: function Games_Tala_vnz_VnzSlotPart$_playerAttack$1(seat, card) {
        /// <param name="seat" type="Number" integer="true">
        /// </param>
        /// <param name="card" type="Number" integer="true">
        /// </param>
        if (seat === 0) {
            var cards = this._cardInHand$1.get_cards();
            cards.remove(card);
            this._cardInHand$1.quickResetCards();
        }
        else {
            this._slots$1[seat].attack(1);
        }
    },
    
    loadContent: function Games_Tala_vnz_VnzSlotPart$loadContent() {
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            this._slots$1[i] = new Games.Tala.vnz.SlotCard(i);
            var slot = this._slots$1[i];
            slot.set_x(0);
            slot.set_y(0);
            slot.set_width(this.get_width());
            slot.set_height(this.get_height());
            this.add(slot);
        }
        this._cardInHand$1 = new Games.Base.Components.CardInHand(Games.Tala.vnz.VnzConstant.space, Games.Tala.vnz.VnzConstant.cardInHandX, Games.Tala.vnz.VnzConstant.cardInHandY);
        this._cardInHand$1.set_x(Games.Tala.vnz.VnzConstant.cardInHandX);
        this._cardInHand$1.set_y(Games.Tala.vnz.VnzConstant.cardInHandY);
        this._cardInHand$1.set_width(this.get_width());
        this._cardInHand$1.set_height(this.get_height());
        this.add(this._cardInHand$1);
        Games.Tala.vnz.VnzSlotPart.callBase(this, 'loadContent');
    },
    
    _onGameStart$1: function Games_Tala_vnz_VnzSlotPart$_onGameStart$1(m) {
        /// <param name="m" type="Games.Tala.YourCards">
        /// </param>
        this._resetParams$1();
        this._chiaBai$1(m);
    },
    
    _resetParams$1: function Games_Tala_vnz_VnzSlotPart$_resetParams$1() {
        this._cardInHand$1.handX = Games.Tala.vnz.VnzConstant.cardInHandX;
        this._cardInHand$1.multiSelect = false;
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            this._slots$1[i].resetParams();
        }
    },
    
    _chiaBai$1: function Games_Tala_vnz_VnzSlotPart$_chiaBai$1(m) {
        /// <param name="m" type="Games.Tala.YourCards">
        /// </param>
        Games.Base.Components.CardSuite.instance.resetAllCards();
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            var user = Games.Tala.TalaState.current.get_session().users[i];
            if (isNullOrUndefined(user)) {
                continue;
            }
            if (Games.Tala.TalaState.current.isPending(user.id)) {
                continue;
            }
            var seat = Games.Tala.TalaState.current.getSeat(user.id);
            if (seat === 0 && Games.Tala.TalaState.current.get_currentUserIsPlayer()) {
                this._cardInHand$1.set_cards(new ZeroScript.Core.List(m.cards));
                this._cardInHand$1.chiaBai();
            }
            else {
                this._slots$1[seat].puzzle();
            }
        }
    },
    
    get_component: function Games_Tala_vnz_VnzSlotPart$get_component() {
        /// <value type="ZeroScript.Core.Games.IComponent"></value>
        return this;
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.vnz.VnzTablePart

Games.Tala.vnz.VnzTablePart = function Games_Tala_vnz_VnzTablePart() {
    /// <field name="_baseImageUrl$1" type="String" static="true">
    /// </field>
    /// <field name="_cardSuiteUrl$1" type="String" static="true">
    /// </field>
    /// <field name="_highLightUrl$1" type="String" static="true">
    /// </field>
    /// <field name="_eatImgUrl$1" type="String" static="true">
    /// </field>
    /// <field name="_markerImgUrl$1" type="String" static="true">
    /// </field>
    /// <field name="_cardType$1" type="Array" elementType="Number" elementInteger="true" static="true">
    /// </field>
    /// <field name="_eatCards$1" type="ZeroScript.Core.List">
    /// </field>
    /// <field name="_view$1" type="Games.Tala.vnz._tableView">
    /// </field>
    /// <field name="_phoms$1" type="Array" elementType="SlotPhom">
    /// </field>
    /// <field name="_allPhoms$1" type="Array" elementType="Phom">
    /// </field>
    /// <field name="_bus$1" type="ZeroScript.Core.IBus">
    /// </field>
    /// <field name="_phomExtractor$1" type="PhomExtractor">
    /// </field>
    /// <field name="_suggestedCard$1" type="Number" integer="true">
    /// </field>
    /// <field name="_selectedCard$1" type="Number" integer="true">
    /// </field>
    /// <field name="_phomShow$1" type="ZeroScript.Core.List">
    /// </field>
    /// <field name="_guis$1" type="ZeroScript.Core.List">
    /// </field>
    /// <field name="_rotateData$1" type="Games.Tala.RotateCardData">
    /// </field>
    /// <field name="_lastCard$1" type="Number" integer="true">
    /// </field>
    /// <field name="_hasPhom$1" type="Boolean">
    /// </field>
    this._phoms$1 = new Array(Games.Tala.TalaState.maxPlayers);
    this._allPhoms$1 = new Array(12);
    Games.Tala.vnz.VnzTablePart.constructBase(this);
    this._phomExtractor$1 = new PhomExtractor();
}
Games.Tala.vnz.VnzTablePart.prototype = {
    _eatCards$1: null,
    _view$1: null,
    _bus$1: null,
    _phomExtractor$1: null,
    _suggestedCard$1: 0,
    _selectedCard$1: 0,
    _phomShow$1: null,
    _guis$1: null,
    _rotateData$1: null,
    _lastCard$1: 0,
    _hasPhom$1: false,
    
    initPart: function Games_Tala_vnz_VnzTablePart$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        this._bus$1 = container.get_bus();
        this._bus$1.subcribe('ClientDevilFishPick', Delegate.create(this, this._onClientPick$1));
        this._bus$1.subcribe('DevilFishPickResponse', Delegate.create(this, this._onPickResponse$1));
        this._bus$1.subcribe('YourCards', Delegate.create(this, this._onGameStart$1));
        this._bus$1.subcribe('GameEnd', Delegate.create(this, this._onGameEnd$1));
        this._bus$1.subcribe('DevilFishEatResponse', Delegate.create(this, this._onEatResponse$1));
        this._bus$1.subcribe('DevilFishShowResponse', Delegate.create(this, this._onShowResponse$1));
        this._bus$1.subcribe('DevilFishUResponse', Delegate.create(this, this._onUResponse$1));
        this._bus$1.subcribe('DevilFishLiveOnResponse', Delegate.create(this, this._onGuiResponse$1));
        this._bus$1.subcribe('player.attack', Delegate.create(this, this._onPlayerAttack$1));
        this._bus$1.subcribe('player.last.attack', Delegate.create(this, this._onLastAttack$1));
        this._bus$1.subcribe('player.show.phom', Delegate.create(this, this._onShowPhomOnly$1));
        this._bus$1.subcribe('require.rotate.card', Delegate.create(this, this._onRotate$1));
    },
    
    _onRotate$1: function Games_Tala_vnz_VnzTablePart$_onRotate$1(d) {
        /// <param name="d" type="Games.Tala.RotateCardData">
        /// </param>
        this._rotateData$1 = d;
    },
    
    _onShowPhomOnly$1: function Games_Tala_vnz_VnzTablePart$_onShowPhomOnly$1(d) {
        /// <param name="d" type="Object">
        /// </param>
        this._phomShow$1 = this._getPhoms$1();
        this._guis$1 = this._getGuis$1(this._phomShow$1);
        for (var i = 0; i < this._phomShow$1.get_count(); i++) {
            var p = this._phomShow$1.get_item(i);
            var arr = p.toArray();
            Games.Base.GameRequest.send('ShowPhom.htm', 'cards', arr);
        }
        for (var i = 0; i < this._guis$1.get_count(); i++) {
            var g = this._guis$1.get_item(i);
            if (isNullOrUndefined(g)) {
                continue;
            }
            Games.Base.GameRequest.send('LiveOn.htm', 'cards', [ g.get_card() ], 'phomId', g.get_phomId(), 'targetId', g.get_phomOwnerId());
        }
    },
    
    _onLastAttack$1: function Games_Tala_vnz_VnzTablePart$_onLastAttack$1(d) {
        /// <param name="d" type="Games.Tala.PlayerAttack">
        /// </param>
        this._selectedCard$1 = d.card;
        this._phomShow$1 = this._getPhoms$1();
        this._guis$1 = this._getGuis$1(this._phomShow$1);
        var hasPhom = this._phomShow$1.get_count() > 0;
        var hasGui = this._hasPhom$1 && this._guiAble$1(this._guis$1);
        if (hasPhom || hasGui) {
            this._view$1.showSuggestPhomDialog(hasPhom, this._phomShow$1);
        }
        else {
            Games.Base.GameRequest.send('Move.htm', 'cards', [ this._selectedCard$1 ]);
        }
    },
    
    _guiAble$1: function Games_Tala_vnz_VnzTablePart$_guiAble$1(guis) {
        /// <param name="guis" type="ZeroScript.Core.List">
        /// </param>
        /// <returns type="Boolean"></returns>
        for (var i = 0; i < guis.get_count(); i++) {
            var g = guis.get_item(i);
            if (g == null) {
                continue;
            }
            return true;
        }
        return false;
    },
    
    _getPhoms$1: function Games_Tala_vnz_VnzTablePart$_getPhoms$1() {
        /// <returns type="ZeroScript.Core.List"></returns>
        var cards = Games.Base.Components.CardInHand.instance.get_cards();
        var remainCards = new ZeroScript.Core.List(cards.toArray());
        if (this._selectedCard$1 >= 0) {
            remainCards.remove(this._selectedCard$1);
        }
        var phoms = this._phomExtractor$1.extract(remainCards.toArray(), this._eatCards$1.toArray());
        return phoms;
    },
    
    _onGameEnd$1: function Games_Tala_vnz_VnzTablePart$_onGameEnd$1(m) {
        /// <param name="m" type="Games.Base.Messages.GameEnd">
        /// </param>
        this._hideSuggest$1();
        var r = m.result;
        if (this._hasPlayerU$1(r)) {
            var seat = Games.Tala.TalaState.current.getSeat(Games.Tala.TalaState.current.currentPlayer);
            for (var i = 0; i < r.uPhoms.length; i++) {
                var cards = r.uPhoms[i];
                if (seat === 1) {
                    this._phoms$1[seat].set_x(Games.Tala.vnz.VnzConstant.groupPhomX[seat]);
                    this._phoms$1[seat].set_y(Games.Tala.vnz.VnzConstant.groupPhomY[seat] + 20);
                }
                this._phoms$1[seat].showPhom(cards, -1, -1);
            }
        }
    },
    
    _hasPlayerU$1: function Games_Tala_vnz_VnzTablePart$_hasPlayerU$1(r) {
        /// <param name="r" type="Games.Tala.DevilFishGameResult">
        /// </param>
        /// <returns type="Boolean"></returns>
        for (var rank = 0; rank < r.finalUserScores.length; rank++) {
            var finalUserScore = r.finalUserScores[rank];
            if (finalUserScore.indexOf('U') >= 0) {
                return true;
            }
        }
        return false;
    },
    
    _onGuiResponse$1: function Games_Tala_vnz_VnzTablePart$_onGuiResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishLiveOnResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            return;
        }
        var fromSeat = Games.Tala.TalaState.current.getSeat(Games.Tala.TalaState.current.currentPlayer);
        var toSeat = Games.Tala.TalaState.current.getSeat(m.targerId);
        this._phoms$1[toSeat].gui(m.cards, fromSeat, m.phomId);
    },
    
    _onUResponse$1: function Games_Tala_vnz_VnzTablePart$_onUResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishUResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            Games.Base.MessageBox.notify('Ch\u01b0a \u00f9 \u0111\u01b0\u1ee3c!');
        }
    },
    
    _onShowResponse$1: function Games_Tala_vnz_VnzTablePart$_onShowResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishShowResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            return;
        }
        var seat = Games.Tala.TalaState.current.getSeat(m.ownerId);
        if (seat === 0) {
            this._hasPhom$1 = true;
            this._phoms$1[seat].set_x(Games.Tala.vnz.VnzConstant.groupPhomX[seat] - m.cards.length * Games.Tala.vnz.VnzConstant.space);
            for (var i = 0; i < m.cards.length; i++) {
                this._eatCards$1.remove(m.cards[i]);
            }
        }
        if (seat === 1) {
            this._phoms$1[seat].set_x(Games.Tala.vnz.VnzConstant.groupPhomX[seat]);
            this._phoms$1[seat].set_y(Games.Tala.vnz.VnzConstant.groupPhomY[seat]);
        }
        this._phoms$1[seat].showPhom(m.cards, m.phomId, m.ownerId);
        var phomSlot = this._getEmptyPhom$1();
        this._allPhoms$1[phomSlot] = new Games.Tala.Phom(new ZeroScript.Core.List(m.cards), m.phomId, m.ownerId);
    },
    
    _getEmptyPhom$1: function Games_Tala_vnz_VnzTablePart$_getEmptyPhom$1() {
        /// <returns type="Number" integer="true"></returns>
        for (var slot = 0; slot < this._allPhoms$1.length; slot++) {
            if (this._allPhoms$1[slot].get_ownerId() === -1) {
                return slot;
            }
        }
        return -1;
    },
    
    _onEatResponse$1: function Games_Tala_vnz_VnzTablePart$_onEatResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishEatResponse">
        /// </param>
        if (!GameError.isOkie(m.error)) {
            return;
        }
        this._hideSuggest$1();
        var id = (m.senderId === 0) ? Games.Tala.TalaState.current.currentPlayer : m.senderId;
        var currentSeat = Games.Tala.TalaState.current.getSeat(id);
        var previousSeat = Games.Tala.TalaState.current.getPreviousSeat(id);
        if (currentSeat === 0 || m.senderId === 0) {
            this._eatCards$1.add(m.card);
        }
        else {
            this._phoms$1[currentSeat].eat(m.card);
        }
        this._view$1.playerEat(previousSeat, m.card);
        if (this._rotateData$1 != null) {
            Debug.writeLine('Rotate from: ' + this._rotateData$1.fromSeat + ' to: ' + this._rotateData$1.toSeat);
            this._view$1.rotateCard(this._rotateData$1.fromSeat, this._rotateData$1.toSeat);
            this._rotateData$1 = null;
        }
    },
    
    _onGameStart$1: function Games_Tala_vnz_VnzTablePart$_onGameStart$1(item) {
        /// <param name="item" type="Games.Tala.YourCards">
        /// </param>
        this._resetParams$1();
        var playerCount = 0;
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            var user = Games.Tala.TalaState.current.get_session().users[i];
            if (isNullOrUndefined(user)) {
                continue;
            }
            playerCount++;
        }
        var pickCount = Games.Tala.TalaState.current.getPickCardsCount(playerCount);
        this._view$1.set_pickCount(pickCount);
    },
    
    _resetParams$1: function Games_Tala_vnz_VnzTablePart$_resetParams$1() {
        this._hasPhom$1 = false;
        this._lastCard$1 = -1;
        this._rotateData$1 = null;
        this._phomShow$1 = new ZeroScript.Core.List();
        this._guis$1 = new ZeroScript.Core.List();
        this._suggestedCard$1 = -1;
        this._selectedCard$1 = -1;
        this._eatCards$1 = new ZeroScript.Core.List();
        this._view$1.resetParams();
        for (var i = 0; i < this._phoms$1.length; i++) {
            this._phoms$1[i].resetParams();
            this._phoms$1[i].set_x(Games.Tala.vnz.VnzConstant.groupPhomX[i]);
            if (i === 1) {
                this._phoms$1[i].set_x(Games.Tala.vnz.VnzConstant.slot1PhomX);
                this._phoms$1[i].set_y(Games.Tala.vnz.VnzConstant.slot1PhomY);
            }
        }
        for (var i = 0; i < this._allPhoms$1.length; i++) {
            this._allPhoms$1[i] = new Games.Tala.Phom(new ZeroScript.Core.List(), -1, -1);
        }
    },
    
    _onPickResponse$1: function Games_Tala_vnz_VnzTablePart$_onPickResponse$1(m) {
        /// <param name="m" type="Games.Tala.DevilFishPickResponse">
        /// </param>
        this._view$1.set_pickCount(m.numOfRemainCards);
        this._hideSuggest$1();
    },
    
    _hideSuggest$1: function Games_Tala_vnz_VnzTablePart$_hideSuggest$1() {
        this._hideSuggestedCard$1();
        this._view$1.suggestPick(false);
    },
    
    _onClientPick$1: function Games_Tala_vnz_VnzTablePart$_onClientPick$1(m) {
        /// <param name="m" type="Games.Tala.ClientDevilFishPick">
        /// </param>
        var seat = Games.Tala.TalaState.current.getSeat(m.senderId);
        this._hideSuggest$1();
        this._view$1.set_pickCount(m.numOfRemainCards);
        this._view$1.playerPick(seat).continueWith(Delegate.create(this, function(c) {
            this._bus$1.publish('player.pick', new Games.Tala.PlayerPick(m.senderId));
        }));
    },
    
    _hideSuggestedCard$1: function Games_Tala_vnz_VnzTablePart$_hideSuggestedCard$1() {
        if (this._suggestedCard$1 < 0) {
            return;
        }
        var c = Games.Base.Components.CardSuite.instance.get(this._suggestedCard$1);
        c.set_eatAble(false);
        this._suggestedCard$1 = -1;
    },
    
    _onPlayerAttack$1: function Games_Tala_vnz_VnzTablePart$_onPlayerAttack$1(d) {
        /// <param name="d" type="Games.Tala.PlayerAttack">
        /// </param>
        var attackerId = d.userId;
        var seat = Games.Tala.TalaState.current.getSeat(attackerId);
        var card = d.card;
        this._lastCard$1 = card;
        this._view$1.playerAttack(seat, card);
        if (Games.Tala.TalaState.current.get_isViewer()) {
            return;
        }
        if (this._canEat$1(card, attackerId)) {
            this._suggestEat$1(card);
        }
        else {
            this._suggestPick$1(attackerId);
        }
    },
    
    _suggestPick$1: function Games_Tala_vnz_VnzTablePart$_suggestPick$1(attackerId) {
        /// <param name="attackerId" type="Number" integer="true">
        /// </param>
        var attackerSeat = Games.Tala.TalaState.current.getSeat(attackerId);
        var previousSeat = Games.Tala.TalaState.current.getPreviousSeat(Global.get_user().id);
        this._view$1.suggestPick(attackerSeat === previousSeat);
    },
    
    _suggestEat$1: function Games_Tala_vnz_VnzTablePart$_suggestEat$1(card) {
        /// <param name="card" type="Number" integer="true">
        /// </param>
        Debug.writeLine('SuggestEat ' + card);
        this._suggestedCard$1 = card;
        var c = Games.Base.Components.CardSuite.instance.get(card);
        c.set_eatAble(true);
    },
    
    _canEat$1: function Games_Tala_vnz_VnzTablePart$_canEat$1(card, attackerId) {
        /// <param name="card" type="Number" integer="true">
        /// </param>
        /// <param name="attackerId" type="Number" integer="true">
        /// </param>
        /// <returns type="Boolean"></returns>
        var attackerSeat = Games.Tala.TalaState.current.getSeat(attackerId);
        var previousSeat = Games.Tala.TalaState.current.getPreviousSeat(Global.get_user().id);
        if (attackerSeat !== previousSeat) {
            return false;
        }
        var cards = Games.Base.Components.CardInHand.instance.get_cards();
        var cardInHands = cards.toArray();
        cardInHands.add(card);
        var eatenCards = this._eatCards$1.toArray();
        eatenCards.add(card);
        var phoms = this._phomExtractor$1.extract(cardInHands, eatenCards);
        var canEat = phoms.get_count() > 0;
        return canEat;
    },
    
    _getGuis$1: function Games_Tala_vnz_VnzTablePart$_getGuis$1(phoms) {
        /// <param name="phoms" type="ZeroScript.Core.List">
        /// </param>
        /// <returns type="ZeroScript.Core.List"></returns>
        var cards = Games.Base.Components.CardInHand.instance.get_cards();
        var remainCards = cards.clone();
        var selected = Games.Base.Components.CardInHand.instance.getSelectedCards();
        if (selected.get_count() > 0 && selected.get_item(selected.get_count() - 1) >= 0) {
            remainCards.remove(selected.get_item(selected.get_count() - 1));
        }
        for (var i = 0; i < phoms.get_count(); i++) {
            var phom = phoms.get_item(i);
            for (var j = 0; j < phom.get_item(j); j++) {
                remainCards.remove(phom.get_item(j));
            }
        }
        var phomDaha = new ZeroScript.Core.List();
        for (var i = 0; i < this._allPhoms$1.length; i++) {
            var g = this._allPhoms$1[i];
            if ((g.get_cards()).get_count() > 2) {
                phomDaha.add(new Games.Tala.Phom(g.get_cards(), g.get_id(), g.get_ownerId()));
            }
        }
        return this._phomExtractor$1.gui(remainCards, phomDaha);
    },
    
    active: function Games_Tala_vnz_VnzTablePart$active() {
        for (var i = 0; i < 52; i++) {
            var card = Games.Base.Components.CardSuite.instance.get(i);
            card.add_click(Delegate.create(this, this._onCardClick$1));
        }
    },
    
    _onCardClick$1: function Games_Tala_vnz_VnzTablePart$_onCardClick$1(sender, x, y) {
        /// <param name="sender" type="ZeroScript.Core.Games.IComponent">
        /// </param>
        /// <param name="x" type="Number" integer="true">
        /// </param>
        /// <param name="y" type="Number" integer="true">
        /// </param>
        var card = sender;
        if (this._checkEatSimple$1(card.get_cardId())) {
            if (this.checkEatComplex(card.get_cardId())) {
                Games.Base.GameRequest.send('Eat.htm');
            }
            else {
                this._view$1.showAnLaoNotify();
            }
        }
    },
    
    checkEatComplex: function Games_Tala_vnz_VnzTablePart$checkEatComplex(card) {
        /// <param name="card" type="Number" integer="true">
        /// </param>
        /// <returns type="Boolean"></returns>
        var list = Games.Base.Components.CardInHand.instance.get_cards();
        var cardInHands = list.toArray();
        cardInHands.add(card);
        var eatenCards = this._eatCards$1.toArray();
        eatenCards.add(card);
        var phoms = this._phomExtractor$1.extract(cardInHands, eatenCards);
        var canEat = phoms.get_count() > 0;
        return canEat;
    },
    
    _checkEatSimple$1: function Games_Tala_vnz_VnzTablePart$_checkEatSimple$1(cardId) {
        /// <param name="cardId" type="Number" integer="true">
        /// </param>
        /// <returns type="Boolean"></returns>
        if (!Games.Tala.TalaState.current.get_isPlaying()) {
            return false;
        }
        if (!Games.Tala.TalaState.current.get_isYourTurn()) {
            return false;
        }
        if (cardId !== this._lastCard$1) {
            return false;
        }
        var cards = Games.Base.Components.CardInHand.instance.get_cards();
        if (cards.contains(cardId)) {
            return false;
        }
        return true;
    },
    
    inActive: function Games_Tala_vnz_VnzTablePart$inActive() {
    },
    
    init: function Games_Tala_vnz_VnzTablePart$init(container) {
        /// <param name="container" type="ZeroScript.Core.Games.IComponentContainer">
        /// </param>
        Games.Tala.vnz.VnzTablePart.callBase(this, 'init', [ container ]);
        this.set_width(Games.Tala.vnz.VnzConstant.viewWidth);
        this.set_height(Games.Tala.vnz.VnzConstant.viewHeight);
        var manager = container.get_contentManager();
        var suiteImg = manager.createImageFromUrl(Games.Tala.vnz.VnzTablePart._cardSuiteUrl$1);
        var downImage = manager.createImage(suiteImg, 0, 4 * Games.Tala.vnz.VnzConstant.cardHeight, Games.Tala.vnz.VnzConstant.cardWidth, Games.Tala.vnz.VnzConstant.cardHeight);
        var highLight = manager.createImageFromUrl(Games.Tala.vnz.VnzTablePart._highLightUrl$1);
        var eat = manager.createImageFromUrl(Games.Tala.vnz.VnzTablePart._eatImgUrl$1);
        var marker = manager.createImageFromUrl(Games.Tala.vnz.VnzTablePart._markerImgUrl$1);
        this._view$1 = new Games.Tala.vnz._tableView();
        this._view$1.set_width(this.get_width());
        this._view$1.set_height(this.get_height());
        this.add(this._view$1);
        this._view$1.add_confirmShow(Delegate.create(this, this._onAutoHaThenAttack$1));
        this._view$1.add_cancelShow(Delegate.create(this, this._onCancelHa$1));
        this._view$1.add_confirmEat(Delegate.create(this, this._onConfirmEat$1));
        var suite = new Games.Base.Components.CardSuite(suiteImg, downImage, Games.Tala.vnz.VnzConstant.cardWidth, Games.Tala.vnz.VnzConstant.cardHeight, highLight, eat, marker);
        suite.set_width(this.get_width());
        suite.set_height(this.get_height());
        suite.set_x(0);
        suite.set_y(0);
        suite.map(Delegate.create(this, this._mapTaLaCards$1));
        this.add(suite);
        for (var i = 0; i < Games.Tala.TalaState.maxPlayers; i++) {
            this._phoms$1[i] = new Games.Tala.vnz.SlotPhom(i);
            var phom = this._phoms$1[i];
            phom.set_x(Games.Tala.vnz.VnzConstant.groupPhomX[i]);
            phom.set_y(Games.Tala.vnz.VnzConstant.groupPhomY[i]);
            phom.set_width(Games.Tala.vnz.VnzConstant.cardWidth * 3);
            phom.set_height(Games.Tala.vnz.VnzConstant.cardHeight * 2);
            phom.add_phomClick(Delegate.create(this, this._onPhomClick$1));
            this.add(phom);
        }
    },
    
    _onConfirmEat$1: function Games_Tala_vnz_VnzTablePart$_onConfirmEat$1() {
        Games.Base.GameRequest.send('Eat.htm');
    },
    
    _onCancelHa$1: function Games_Tala_vnz_VnzTablePart$_onCancelHa$1() {
        Games.Base.GameRequest.send('Move.htm', 'cards', [ this._selectedCard$1 ]);
    },
    
    _onAutoHaThenAttack$1: function Games_Tala_vnz_VnzTablePart$_onAutoHaThenAttack$1() {
        var attackCard = [ this._selectedCard$1 ];
        var guiString = '';
        for (var i = 0; i < this._guis$1.get_count(); i++) {
            var g = this._guis$1.get_item(i);
            if (g != null) {
                guiString += String.format('{0},{1},{2},', g.get_card(), g.get_phomId(), g.get_phomOwnerId());
            }
        }
        if (isNullOrUndefined(this._phomShow$1) || this._phomShow$1.get_count() === 0) {
            for (var i = 0; i < this._guis$1.get_count(); i++) {
                var g = this._guis$1.get_item(i);
                if (g != null) {
                    Games.Base.GameRequest.send('LiveOn.htm', 'cards', g.get_card(), 'phomId', g.get_phomId(), 'targetId', g.get_phomOwnerId());
                }
            }
            Games.Base.GameRequest.send('Move.htm', 'cards', attackCard);
        }
        else {
            var p0 = (isNullOrUndefined(this._phomShow$1.get_item(0))) ? new Array(0) : (this._phomShow$1.get_item(0)).toArray();
            var p1 = (isNullOrUndefined(this._phomShow$1.get_item(1))) ? new Array(1) : (this._phomShow$1.get_item(1)).toArray();
            var p2 = (isNullOrUndefined(this._phomShow$1.get_item(2))) ? new Array(2) : (this._phomShow$1.get_item(2)).toArray();
            Games.Base.GameRequest.send('ShowThenAttack.htm', 'cards', attackCard, 'phom0', p0.toString(), 'phom1', p1.toString(), 'phom2', p2.toString(), 'guis', guiString);
        }
    },
    
    _onPhomClick$1: function Games_Tala_vnz_VnzTablePart$_onPhomClick$1(phomId, ownerId) {
        /// <param name="phomId" type="Number" integer="true">
        /// </param>
        /// <param name="ownerId" type="Number" integer="true">
        /// </param>
        var cards = Games.Base.Components.CardInHand.instance.getSelectedCards();
        Games.Base.GameRequest.send('LiveOn.htm', 'cards', cards.toArray(), 'phomId', phomId, 'targetId', ownerId);
    },
    
    _mapTaLaCards$1: function Games_Tala_vnz_VnzTablePart$_mapTaLaCards$1(x, y) {
        /// <param name="x" type="Number" integer="true">
        /// </param>
        /// <param name="y" type="Number" integer="true">
        /// </param>
        /// <returns type="Number" integer="true"></returns>
        return Games.Tala.vnz.VnzTablePart._cardType$1[y] * 13 + x;
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.vnz.VnzTalaAnimation

Games.Tala.vnz.VnzTalaAnimation = function Games_Tala_vnz_VnzTalaAnimation() {
    /// <field name="_baseImageUrl$1" type="String" static="true">
    /// </field>
    /// <field name="_u$1" type="String" static="true">
    /// </field>
    /// <field name="_chot$1" type="String" static="true">
    /// </field>
    /// <field name="_mom$1" type="String" static="true">
    /// </field>
    /// <field name="_uden$1" type="String" static="true">
    /// </field>
    /// <field name="_dic$1" type="Array" elementType="ImageComponent">
    /// </field>
    this._dic$1 = [];
    Games.Tala.vnz.VnzTalaAnimation.constructBase(this);
}
Games.Tala.vnz.VnzTalaAnimation.prototype = {
    
    init: function Games_Tala_vnz_VnzTalaAnimation$init(container) {
        /// <param name="container" type="ZeroScript.Core.Games.IComponentContainer">
        /// </param>
        Games.Tala.vnz.VnzTalaAnimation.callBase(this, 'init', [ container ]);
        var u = new ZeroScript.Core.Games.ImageComponent(Games.Tala.vnz.VnzTalaAnimation._u$1);
        var chot = new ZeroScript.Core.Games.ImageComponent(Games.Tala.vnz.VnzTalaAnimation._chot$1);
        var mom = new ZeroScript.Core.Games.ImageComponent(Games.Tala.vnz.VnzTalaAnimation._mom$1);
        var uden = new ZeroScript.Core.Games.ImageComponent(Games.Tala.vnz.VnzTalaAnimation._uden$1);
        this._addElement$1(Games.Tala.DevilFishTransactionReason.denLang, uden);
        this._addElement$1(Games.Tala.DevilFishTransactionReason.uDen, uden);
        this._addElement$1(Games.Tala.DevilFishTransactionReason.uf, u);
        this._addElement$1(Games.Tala.DevilFishTransactionReason.ufKhan, u);
        this._addElement$1(Games.Tala.DevilFishTransactionReason.anChot, chot);
        this._addElement$1(Games.Tala.DevilFishTransactionReason.moms, mom);
    },
    
    _addElement$1: function Games_Tala_vnz_VnzTalaAnimation$_addElement$1(reason, img) {
        /// <param name="reason" type="Number" integer="true">
        /// </param>
        /// <param name="img" type="ZeroScript.Core.Games.ImageComponent">
        /// </param>
        this._dic$1[reason] = img;
        this._hideElement$1(img);
        this.add(img);
    },
    
    _hideElement$1: function Games_Tala_vnz_VnzTalaAnimation$_hideElement$1(img) {
        /// <param name="img" type="ZeroScript.Core.Games.ImageComponent">
        /// </param>
        img.set_x(250);
        img.set_y(550);
    },
    
    initPart: function Games_Tala_vnz_VnzTalaAnimation$initPart(container) {
        /// <param name="container" type="ZeroScript.Core.Parts.IPartContainer">
        /// </param>
        var bus = container.get_bus();
        bus.subcribe('YourCards', Delegate.create(this, this._onGameStart$1));
        bus.subcribe('NewTransaction', Delegate.create(this, this._animate$1));
    },
    
    _onGameStart$1: function Games_Tala_vnz_VnzTalaAnimation$_onGameStart$1(m) {
        /// <param name="m" type="Games.Tala.YourCards">
        /// </param>
        for (var i = 0; i < this._dic$1.length; i++) {
            if (this._dic$1[i] == null) {
                continue;
            }
            this._hideElement$1(this._dic$1[i]);
        }
    },
    
    _animate$1: function Games_Tala_vnz_VnzTalaAnimation$_animate$1(e) {
        /// <param name="e" type="Games.Tala.NewTransaction">
        /// </param>
        var notifier = this._dic$1[e.reason];
        if (notifier == null) {
            return;
        }
        var x = notifier.get_x();
        notifier.bringToFront();
        var dur = 350;
        var stay = 800;
        notifier.set_x(x);
        notifier.set_y(150);
        notifier.rotate(0, 360, dur).continueWith(Delegate.create(this, function(c) {
            notifier.moveAfterDelay(x, 100, x, -300, dur, stay);
        }));
    },
    
    active: function Games_Tala_vnz_VnzTalaAnimation$active() {
    },
    
    inActive: function Games_Tala_vnz_VnzTalaAnimation$inActive() {
    }
}


////////////////////////////////////////////////////////////////////////////////
// Games.Tala.vnz.VnzTalaSoundPart

Games.Tala.vnz.VnzTalaSoundPart = function Games_Tala_vnz_VnzTalaSoundPart() {
    Games.Tala.vnz.VnzTalaSoundPart.constructBase(this);
}
Games.Tala.vnz.VnzTalaSoundPart.prototype = {
    
    init: function Games_Tala_vnz_VnzTalaSoundPart$init(container) {
        /// <param name="container" type="ZeroScript.Core.Games.IComponentContainer">
        /// </param>
        Games.Tala.vnz.VnzTalaSoundPart.callBase(this, 'init', [ container ]);
        this.sound = container.get_soundManager();
        this.sound.add_onLoaded(Delegate.create(this, this._onLoaded$2));
        this.sound.appendTo(document.body);
    },
    
    _onLoaded$2: function Games_Tala_vnz_VnzTalaSoundPart$_onLoaded$2() {
        Debug.writeLine('Sound Loaded');
        this.sound.add(Games.Base.Messages.GamePlaySound.join, '_Resources/_Common/mp3/join.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.leave, '_Resources/_Common/mp3/Leave.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.start, '_Resources/_Common/mp3/mario/1up.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.yourTurn, '_Resources/_Common/mp3/Turn.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.error, '_Resources/_Common/mp3/error.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.win, '_Resources/_Common/mp3/mario/Win_Stage.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.lose, '_Resources/_Common/mp3/mario/death.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.alarm, '_Resources/_Common/mp3/car.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.shipBell, '_Resources/_Common/mp3/shipbell.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.throwCard, '_Resources/_Common/mp3/card/throwCard.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.danh, '_Resources/_Common/mp3/mario/Mario_Jump.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.an, '_Resources/_Common/mp3/mario/coin.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.anChot, '_Resources/_Common/mp3/mario/1up.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.gui, '_Resources/_Common/mp3/mario/coin.mp3');
        this.sound.add(Games.Base.Messages.GamePlaySound.ha, '_Resources/_Common/mp3/mario/coin.mp3');
        var map = {};
        map['ext.player.join'] = Games.Base.Messages.GamePlaySound.join;
        map['ext.player.leave'] = Games.Base.Messages.GamePlaySound.leave;
        map['ext.win'] = Games.Base.Messages.GamePlaySound.win;
        map['ext.lose'] = Games.Base.Messages.GamePlaySound.lose;
        map['ext.halfTime'] = Games.Base.Messages.GamePlaySound.shipBell;
        map['ext.yourTurn'] = Games.Base.Messages.GamePlaySound.yourTurn;
        map['ext.error'] = Games.Base.Messages.GamePlaySound.error;
        map['ext.start'] = Games.Base.Messages.GamePlaySound.start;
        map['ext.throw.card'] = Games.Base.Messages.GamePlaySound.throwCard;
        map['ext.player.danh'] = Games.Base.Messages.GamePlaySound.danh;
        map['ext.player.an'] = Games.Base.Messages.GamePlaySound.an;
        map['ext.player.anchot'] = Games.Base.Messages.GamePlaySound.anChot;
        map['ext.player.gui'] = Games.Base.Messages.GamePlaySound.gui;
        map['ext.player.ha'] = Games.Base.Messages.GamePlaySound.ha;
        this.map(map);
    }
}


Games.Tala.ActionPart.createClass('Games.Tala.ActionPart', ZeroScript.Core.Parts.BasePart);
Games.Tala.ActionView.createClass('Games.Tala.ActionView');
Games.Tala.ActivityPart.createClass('Games.Tala.ActivityPart', ZeroScript.Core.Parts.BasePart);
Games.Tala.BubblePart.createClass('Games.Tala.BubblePart', ZeroScript.Core.Parts.BasePart);
Games.Tala.BubbleView.createClass('Games.Tala.BubbleView');
Games.Tala.GuiPhom.createClass('Games.Tala.GuiPhom');
Games.Tala.Phom.createClass('Games.Tala.Phom');
PhomExtractor.createClass('PhomExtractor');
Games.Tala.PhomGroup.createClass('Games.Tala.PhomGroup', ZeroScript.Core.Games.BaseComponent);
Games.Tala.SlotPhom.createClass('Games.Tala.SlotPhom', ZeroScript.Core.Games.BaseComponent);
Games.Tala.Picker.createClass('Games.Tala.Picker', ZeroScript.Core.Games.BaseComponent);
Games.Tala.MobieResultPart.createClass('Games.Tala.MobieResultPart', ZeroScript.Core.Parts.BasePart);
Games.Tala.ResultPart.createClass('Games.Tala.ResultPart', Games.Parts.Plays.BaseResultPart);
Games.Tala.SlotCard.createClass('Games.Tala.SlotCard', ZeroScript.Core.Games.BaseComponent);
Games.Tala.GameMenu.createClass('Games.Tala.GameMenu', ZeroScript.Core.Parts.BasePart);
Games.Tala.DevilFishGameResult.createClass('Games.Tala.DevilFishGameResult', Games.Base.Messages.BaseGameResult);
Games.Tala.DfAction.createClass('Games.Tala.DfAction');
Games.Tala.DfGameError.createClass('Games.Tala.DfGameError');
Games.Tala.DfUserResult.createClass('Games.Tala.DfUserResult', Games.Base.Messages.UserResult);
Games.Tala.PlayerAttack.createClass('Games.Tala.PlayerAttack');
Games.Tala.RotateCardData.createClass('Games.Tala.RotateCardData');
Games.Tala.PlayerPick.createClass('Games.Tala.PlayerPick');
Games.Tala.SlotPart.createClass('Games.Tala.SlotPart', ZeroScript.Core.Games.BaseComponent, ZeroScript.Core.Parts.IPart);
Games.Tala.PlayerPart.createClass('Games.Tala.PlayerPart', ZeroScript.Core.Games.BaseComponent, ZeroScript.Core.Parts.IPart);
Games.Tala.PlayerView.createClass('Games.Tala.PlayerView');
Games.Tala.VmgPhoneCardSuite.createClass('Games.Tala.VmgPhoneCardSuite', Games.Base.Components.BaseCardSuite);
Games.Tala.VmgPhoneCardInHand.createClass('Games.Tala.VmgPhoneCardInHand', ZeroScript.Core.Games.BaseComponent);
Games.Tala.TablePart.createClass('Games.Tala.TablePart', ZeroScript.Core.Games.BaseComponent, ZeroScript.Core.Parts.IPart);
Games.Tala._tableView.createClass('Games.Tala._tableView', ZeroScript.Core.Games.BaseComponent);
Games.Tala.TalaAnimation.createClass('Games.Tala.TalaAnimation', ZeroScript.Core.Games.BaseComponent, ZeroScript.Core.Parts.IPart);
Games.Tala.TalaCardGroup.createClass('Games.Tala.TalaCardGroup', ZeroScript.Core.Games.BaseComponent);
Games.Tala.VmgPhoneConstant.createClass('Games.Tala.VmgPhoneConstant');
Games.Tala.TalaModule.createClass('Games.Tala.TalaModule');
Games.Tala.TalaState.createClass('Games.Tala.TalaState', ZeroScript.Core.Parts.BasePart);
Games.Tala.TalaSoundPart.createClass('Games.Tala.TalaSoundPart', Games.Parts.Plays.SoundPart);
Games.Tala.Parts.Fb.FbSlotCard.createClass('Games.Tala.Parts.Fb.FbSlotCard', ZeroScript.Core.Games.BaseComponent);
Games.Tala.Parts.Fb.FbSlotPhom.createClass('Games.Tala.Parts.Fb.FbSlotPhom', ZeroScript.Core.Games.BaseComponent);
Games.Tala.Parts.Fb._fbTableView.createClass('Games.Tala.Parts.Fb._fbTableView', ZeroScript.Core.Games.BaseComponent);
Games.Tala.Parts.Fb.FbActionPart.createClass('Games.Tala.Parts.Fb.FbActionPart', ZeroScript.Core.Parts.BasePart);
Games.Tala.Parts.Fb.FbConstant.createClass('Games.Tala.Parts.Fb.FbConstant');
Games.Tala.Parts.Fb.FbPlayerPart.createClass('Games.Tala.Parts.Fb.FbPlayerPart', ZeroScript.Core.Games.BaseComponent, ZeroScript.Core.Parts.IPart);
Games.Tala.Parts.Fb.FbSlotPart.createClass('Games.Tala.Parts.Fb.FbSlotPart', ZeroScript.Core.Games.BaseComponent, ZeroScript.Core.Parts.IPart);
Games.Tala.Parts.Fb.FbTablePart.createClass('Games.Tala.Parts.Fb.FbTablePart', ZeroScript.Core.Games.BaseComponent, ZeroScript.Core.Parts.IPart);
Games.Tala.Parts.Fb.PhomGroup.createClass('Games.Tala.Parts.Fb.PhomGroup', ZeroScript.Core.Games.BaseComponent);
Games.Tala.Parts.Fb.Picker.createClass('Games.Tala.Parts.Fb.Picker', ZeroScript.Core.Games.BaseComponent);
Games.Tala.Parts.Fb.PlayerView.createClass('Games.Tala.Parts.Fb.PlayerView');
Games.Tala.Parts.Fb.SlotCard.createClass('Games.Tala.Parts.Fb.SlotCard', ZeroScript.Core.Games.BaseComponent);
Games.Tala.Parts.Fb.SlotPhom.createClass('Games.Tala.Parts.Fb.SlotPhom', ZeroScript.Core.Games.BaseComponent);
Games.Tala.vnz.ActionView.createClass('Games.Tala.vnz.ActionView');
Games.Tala.vnz.BubbleView.createClass('Games.Tala.vnz.BubbleView');
Games.Tala.vnz.PhomGroup.createClass('Games.Tala.vnz.PhomGroup', ZeroScript.Core.Games.BaseComponent);
Games.Tala.vnz.Picker.createClass('Games.Tala.vnz.Picker', ZeroScript.Core.Games.BaseComponent);
Games.Tala.vnz.PlayerView.createClass('Games.Tala.vnz.PlayerView');
Games.Tala.vnz.SlotCard.createClass('Games.Tala.vnz.SlotCard', ZeroScript.Core.Games.BaseComponent);
Games.Tala.vnz.SlotPhom.createClass('Games.Tala.vnz.SlotPhom', ZeroScript.Core.Games.BaseComponent);
Games.Tala.vnz._tableView.createClass('Games.Tala.vnz._tableView', ZeroScript.Core.Games.BaseComponent);
Games.Tala.vnz.TalaCardGroup.createClass('Games.Tala.vnz.TalaCardGroup', ZeroScript.Core.Games.BaseComponent);
Games.Tala.vnz.VnzActionPart.createClass('Games.Tala.vnz.VnzActionPart', ZeroScript.Core.Parts.BasePart);
Games.Tala.vnz.VnzActivityPart.createClass('Games.Tala.vnz.VnzActivityPart', ZeroScript.Core.Parts.BasePart);
Games.Tala.vnz.VnzBubblePart.createClass('Games.Tala.vnz.VnzBubblePart', ZeroScript.Core.Parts.BasePart);
Games.Tala.vnz.VnzConstant.createClass('Games.Tala.vnz.VnzConstant');
Games.Tala.vnz.VnzGameMenu.createClass('Games.Tala.vnz.VnzGameMenu', ZeroScript.Core.Parts.BasePart);
Games.Tala.vnz.VnzPlayerPart.createClass('Games.Tala.vnz.VnzPlayerPart', ZeroScript.Core.Games.BaseComponent, ZeroScript.Core.Parts.IPart);
Games.Tala.vnz.VnzResultPart.createClass('Games.Tala.vnz.VnzResultPart', Games.Parts.Plays.BaseResultPart);
Games.Tala.vnz.VnzSlotPart.createClass('Games.Tala.vnz.VnzSlotPart', ZeroScript.Core.Games.BaseComponent, ZeroScript.Core.Parts.IPart);
Games.Tala.vnz.VnzTablePart.createClass('Games.Tala.vnz.VnzTablePart', ZeroScript.Core.Games.BaseComponent, ZeroScript.Core.Parts.IPart);
Games.Tala.vnz.VnzTalaAnimation.createClass('Games.Tala.vnz.VnzTalaAnimation', ZeroScript.Core.Games.BaseComponent, ZeroScript.Core.Parts.IPart);
Games.Tala.vnz.VnzTalaSoundPart.createClass('Games.Tala.vnz.VnzTalaSoundPart', Games.Parts.Plays.SoundPart);
Games.Tala.BubblePart._maxPlayers$1 = 10;
Games.Tala.BubbleView._commboTime = 3000;
PhomExtractor._cardEaten = 2;
Games.Tala.PhomGroup._dur$1 = 500;
Games.Tala.MobieResultPart.u = 'U';
Games.Tala.MobieResultPart.uKhan = 'UKhan';
Games.Tala.MobieResultPart.mom = 'Mom';
Games.Tala.MobieResultPart.uDen = 'UDen';
Games.Tala.MobieResultPart.denLang = 'DenLang';
Games.Tala.MobieResultPart.empty = '';
Games.Tala.MobieResultPart._resultTexts$1 = {};
Games.Tala.MobieResultPart._resultTexts$1[Games.Tala.MobieResultPart.u] = 'u';
Games.Tala.MobieResultPart._resultTexts$1[Games.Tala.MobieResultPart.uKhan] = 'u';
Games.Tala.MobieResultPart._resultTexts$1[Games.Tala.MobieResultPart.mom] = 'mom';
Games.Tala.MobieResultPart._resultTexts$1[Games.Tala.MobieResultPart.uDen] = 'uden';
Games.Tala.MobieResultPart._resultTexts$1[Games.Tala.MobieResultPart.denLang] = 'denlang';
Games.Tala.MobieResultPart._resultTexts$1[Games.Tala.MobieResultPart.empty] = '_';
Games.Tala.ResultPart.u = 'U';
Games.Tala.ResultPart.uKhan = 'UKhan';
Games.Tala.ResultPart.mom = 'Mom';
Games.Tala.ResultPart.uDen = 'UDen';
Games.Tala.ResultPart.denLang = 'DenLang';
Games.Tala.ResultPart.leaveGame = 'LeaveGame';
Games.Tala.ResultPart.empty = '';
Games.Tala.ResultPart._resultTexts$2 = {};
Games.Tala.ResultPart._resultTexts$2[Games.Tala.ResultPart.u] = '\u00d9!!!';
Games.Tala.ResultPart._resultTexts$2[Games.Tala.ResultPart.uKhan] = '\u00d9 khan';
Games.Tala.ResultPart._resultTexts$2[Games.Tala.ResultPart.mom] = 'M\u00f3m';
Games.Tala.ResultPart._resultTexts$2[Games.Tala.ResultPart.uDen] = '\u00d9 \u0111\u1ec1n';
Games.Tala.ResultPart._resultTexts$2[Games.Tala.ResultPart.denLang] = '\u0110\u1ec1n l\u00e0ng';
Games.Tala.ResultPart._resultTexts$2[Games.Tala.ResultPart.leaveGame] = 'B\u1ecf cu\u1ed9c';
Games.Tala.ResultPart._resultTexts$2[Games.Tala.ResultPart.empty] = '_';
Games.Tala.DfAction.startGame = 100;
Games.Tala.DfAction.pick = 101;
Games.Tala.DfAction.move = 102;
Games.Tala.DfAction.liveOn = 103;
Games.Tala.DfAction.show = 104;
Games.Tala.DfAction.eat = 105;
Games.Tala.DfGameError.haDauKhongDuocGui = -200;
Games.Tala.DfGameError.anLao = -201;
Games.Tala.DfGameError.guiKhongDungPhom = -202;
Games.Tala.DfGameError.khongDuocDanhCardDaAn = -203;
Games.Tala.DfGameError.haKhongDungPhom = -204;
Games.Tala.DfGameError.chuaDuocHa = -205;
Games.Tala.DfGameError.khongDuocGuiCardDaAn = -206;
Games.Tala.DfGameError.cardsHaPhaiLaPhom = -207;
Games.Tala.DfGameError.khongCoPhomKhongDuocGui = -208;
Games.Tala.DfGameError.anHoacBocRoiKhongDuocAnNua = -209;
Games.Tala.DfGameError.anRoiKhongDuocAnNua = -309;
Games.Tala.DfGameError.bocRoiKhongDuocAnNua = -310;
Games.Tala.DfGameError.invalidActionBoc = -311;
Games.Tala.DfGameError.invalidActionHa = -312;
Games.Tala.DfGameError.invalidActionU = -313;
Games.Tala.DfGameError.playerDoesntHaveOneOfTheseCards = -314;
Games.Tala.DfGameError.khongDuocAnQua3Cards = -2010;
Games.Tala.DfGameError.khongDuocAnCardCuaQuitter = -2011;
Games.Tala.VmgPhoneCardSuite.instance = null;
Games.Tala.VmgPhoneCardInHand._liftDuration$1 = 300;
Games.Tala.VmgPhoneCardInHand.instance = null;
Games.Tala.TablePart._baseImageUrl$1 = '_Resources/TaLa/img/';
Games.Tala.TablePart._highLightUrl$1 = Games.Tala.TablePart._baseImageUrl$1 + 'v.jpg';
Games.Tala.TablePart._eatImgUrl$1 = Games.Tala.TablePart._baseImageUrl$1 + 'suggest_eat.png';
Games.Tala.TablePart._markerImgUrl$1 = Games.Tala.TablePart._baseImageUrl$1 + 'grg_card_overlay.png';
Games.Tala.TablePart._cardType$1 = [ 3, 2, 1, 0 ];
Games.Tala.TalaAnimation._baseImageUrl$1 = '_Resources/TaLa/img/';
Games.Tala.TalaAnimation._u$1 = Games.Tala.TalaAnimation._baseImageUrl$1 + 'u.png';
Games.Tala.TalaAnimation._chot$1 = Games.Tala.TalaAnimation._baseImageUrl$1 + 'an_cay_chot.png';
Games.Tala.TalaAnimation._mom$1 = Games.Tala.TalaAnimation._baseImageUrl$1 + 'mom.png';
Games.Tala.TalaAnimation._uden$1 = Games.Tala.TalaAnimation._baseImageUrl$1 + 'u_den.png';
Games.Tala.TalaCardGroup._attachDuration$1 = 500;
Games.Tala.VmgPhoneConstant.cardSuiteUrl = '_Resources/TaLa/img/cards.png';
Games.Tala.VmgPhoneConstant.bigCardSuiteUrl = '_Resources/TaLa/img/big_cards.png';
Games.Tala.VmgPhoneConstant.facedownUrl = '_Resources/TaLa/img/faceDown_phone.png';
Games.Tala.VmgPhoneConstant.spaceInHand = 64;
Games.Tala.VmgPhoneConstant.spaceInPhomW = 35;
Games.Tala.VmgPhoneConstant.spaceInPhomH = 40;
Games.Tala.VmgPhoneConstant.space = 20;
Games.Tala.VmgPhoneConstant.pickX = 445;
Games.Tala.VmgPhoneConstant.pickY = 203;
Games.Tala.VmgPhoneConstant.cardInHandX = 85;
Games.Tala.VmgPhoneConstant.cardInHandY = 390;
Games.Tala.VmgPhoneConstant.cardWidth = 66;
Games.Tala.VmgPhoneConstant.cardHeight = 92;
Games.Tala.VmgPhoneConstant.bigCardWidth = 84;
Games.Tala.VmgPhoneConstant.bigCardHeight = 114;
Games.Tala.VmgPhoneConstant.bigSpaceInHand = 84;
Games.Tala.VmgPhoneConstant.viewWidth = 960;
Games.Tala.VmgPhoneConstant.viewHeight = 536;
Games.Tala.VmgPhoneConstant.groupPhomX = [ 120, 700, 510, 100 ];
Games.Tala.VmgPhoneConstant.groupPhomY = [ 390, 170, 0, 170 ];
Games.Tala.VmgPhoneConstant.cardDaDanhXs = [ 410, 515, 410, 315 ];
Games.Tala.VmgPhoneConstant.cardDaDanhYs = [ 298, 203, 108, 203 ];
Games.Tala.VmgPhoneConstant.avatarsX = [ 570, 890, 320, 40 ];
Games.Tala.VmgPhoneConstant.avatarsY = [ 360, 135, 60, 120 ];
Games.Tala.VmgPhoneConstant.handXs = [ 190, 875, 320, 15 ];
Games.Tala.VmgPhoneConstant.handYs = [ 410, 85, 0, 100 ];
Games.Tala.VmgPhoneConstant.cardDaHaX = [ [ 0, 150, 300 ], [ 0, 0, 0 ], [ 0, 150, 300 ], [ 0, 0, 0 ] ];
Games.Tala.VmgPhoneConstant.cardDaHaY = [ [ 0, 0, 0 ], [ 0, 40, 80 ], [ 0, 0, 0 ], [ 0, 40, 80 ] ];
Games.Tala.VmgPhoneConstant.handDirects = [ Games.Base.Components.ExpandDirect.right, Games.Base.Components.ExpandDirect.down, Games.Base.Components.ExpandDirect.right, Games.Base.Components.ExpandDirect.down ];
Games.Tala.VmgPhoneConstant.phomExpands = [ Games.Base.Components.ExpandDirect.right, Games.Base.Components.ExpandDirect.right, Games.Base.Components.ExpandDirect.right, Games.Base.Components.ExpandDirect.right ];
Games.Tala.VmgPhoneConstant.phomOrders = [ [ 0, 1, 2 ], [ 0, 1, 2 ], [ 0, 1, 2 ], [ 0, 1, 2 ] ];
ZeroScript.Core.Modules.add('Games.Tala.TalaModule');
Games.Tala.TalaState.current = null;
Games.Tala.TalaState.maxPlayers = 4;
Games.Tala.Parts.Fb.FbConstant.cardSuiteUrl = '_Resources/TaLa/img/grg_allcards.png';
Games.Tala.Parts.Fb.FbConstant.space = 20;
Games.Tala.Parts.Fb.FbConstant.centerX = 395;
Games.Tala.Parts.Fb.FbConstant.centerY = 190;
Games.Tala.Parts.Fb.FbConstant.directions = [ Games.Base.Components.ExpandDirect.right, Games.Base.Components.ExpandDirect.up, Games.Base.Components.ExpandDirect.left, Games.Base.Components.ExpandDirect.down ];
Games.Tala.Parts.Fb.FbConstant.cardWidth = 45;
Games.Tala.Parts.Fb.FbConstant.cardHeight = 60;
Games.Tala.Parts.Fb.FbConstant.viewWidth = 760;
Games.Tala.Parts.Fb.FbConstant.viewHeight = 500;
Games.Tala.Parts.Fb.FbConstant.groupPhomX = [ 520, 470, 240, 215 ];
Games.Tala.Parts.Fb.FbConstant.groupPhomY = [ 280, 130, 21, 130 ];
Games.Tala.Parts.Fb.FbConstant.slot1PhomX = 570;
Games.Tala.Parts.Fb.FbConstant.slot1PhomY = 171;
Games.Tala.Parts.Fb.FbConstant.slot3PhomX = 115;
Games.Tala.Parts.Fb.FbConstant.slot3PhomY = 185;
Games.Tala.Parts.Fb.FbConstant.cardDaDanhXs = [ 368, 446, 368, 285 ];
Games.Tala.Parts.Fb.FbConstant.cardDaDanhYs = [ 255, 190, 125, 190 ];
Games.Tala.Parts.Fb.FbConstant.avatarsX = [ 225, 620, 530, 150 ];
Games.Tala.Parts.Fb.FbConstant.avatarsY = [ 320, 290, 20, 90 ];
Games.Tala.Parts.Fb.FbConstant.cardInHandX = 295;
Games.Tala.Parts.Fb.FbConstant.cardInHandY = 340;
Games.Tala.Parts.Fb.FbConstant.handXs = [ 295, 609, 418, 164 ];
Games.Tala.Parts.Fb.FbConstant.handYs = [ 340, 165, 21, 185 ];
Games.Tala.Parts.Fb.FbConstant.cardDaHaX = [ [ 0, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 0 ] ];
Games.Tala.Parts.Fb.FbConstant.cardDaHaY = [ [ 60, 30, 0 ], [ 0, 30, 60 ], [ 0, 30, 60 ], [ 0, 30, 60 ] ];
Games.Tala.Parts.Fb.FbConstant.expands = [ Games.Base.Components.ExpandDirect.right, Games.Base.Components.ExpandDirect.left, Games.Base.Components.ExpandDirect.left, Games.Base.Components.ExpandDirect.right ];
Games.Tala.Parts.Fb.FbConstant.orders = [ [ 2, 1, 0 ], [ 0, 1, 2 ], [ 0, 1, 2 ], [ 0, 1, 2 ] ];
Games.Tala.Parts.Fb.FbTablePart._baseImageUrl$1 = '_Resources/TaLa/img/';
Games.Tala.Parts.Fb.FbTablePart._cardSuiteUrl$1 = Games.Tala.Parts.Fb.FbTablePart._baseImageUrl$1 + 'grg_allcards.png';
Games.Tala.Parts.Fb.FbTablePart._highLightUrl$1 = Games.Tala.Parts.Fb.FbTablePart._baseImageUrl$1 + 'v.jpg';
Games.Tala.Parts.Fb.FbTablePart._eatImgUrl$1 = Games.Tala.Parts.Fb.FbTablePart._baseImageUrl$1 + 'suggest_eat.png';
Games.Tala.Parts.Fb.FbTablePart._markerImgUrl$1 = Games.Tala.Parts.Fb.FbTablePart._baseImageUrl$1 + 'grg_card_overlay.png';
Games.Tala.Parts.Fb.FbTablePart._cardType$1 = [ 3, 2, 1, 0 ];
Games.Tala.Parts.Fb.PhomGroup._dur$1 = 500;
Games.Tala.Parts.Fb.PhomGroup._space$1 = 20;
Games.Tala.vnz.BubbleView._commboTime = 3000;
Games.Tala.vnz.PhomGroup._dur$1 = 500;
Games.Tala.vnz.PhomGroup._space$1 = 20;
Games.Tala.vnz.TalaCardGroup._attachDuration$1 = 500;
Games.Tala.vnz.VnzBubblePart._maxPlayers$1 = 20;
Games.Tala.vnz.VnzConstant.cardSuiteUrl = '_Resources/TaLa/img/grg_allcards.png';
Games.Tala.vnz.VnzConstant.space = 20;
Games.Tala.vnz.VnzConstant.centerX = 357;
Games.Tala.vnz.VnzConstant.centerY = 225;
Games.Tala.vnz.VnzConstant.directions = [ Games.Base.Components.ExpandDirect.right, Games.Base.Components.ExpandDirect.up, Games.Base.Components.ExpandDirect.left, Games.Base.Components.ExpandDirect.down ];
Games.Tala.vnz.VnzConstant.cardWidth = 45;
Games.Tala.vnz.VnzConstant.cardHeight = 60;
Games.Tala.vnz.VnzConstant.viewWidth = 630;
Games.Tala.vnz.VnzConstant.viewHeight = 500;
Games.Tala.vnz.VnzConstant.groupPhomX = [ 500, 439, 190, 119 ];
Games.Tala.vnz.VnzConstant.groupPhomY = [ 327, 135, 23, 260 ];
Games.Tala.vnz.VnzConstant.slot1PhomX = 486;
Games.Tala.vnz.VnzConstant.slot1PhomY = 90;
Games.Tala.vnz.VnzConstant.cardDaDanhXs = [ 330, 408, 330, 245 ];
Games.Tala.vnz.VnzConstant.cardDaDanhYs = [ 290, 225, 160, 225 ];
Games.Tala.vnz.VnzConstant.avatarsX = [ 200, 555, 490, 125 ];
Games.Tala.vnz.VnzConstant.avatarsY = [ 370, 260, 20, 35 ];
Games.Tala.vnz.VnzConstant.cardInHandX = 275;
Games.Tala.vnz.VnzConstant.cardInHandY = 387;
Games.Tala.vnz.VnzConstant.handXs = [ 280, 576, 380, 119 ];
Games.Tala.vnz.VnzConstant.handYs = [ 380, 145, 23, 152 ];
Games.Tala.vnz.VnzConstant.cardDaHaX = [ [ 0, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 0 ] ];
Games.Tala.vnz.VnzConstant.cardDaHaY = [ [ 60, 30, 0 ], [ 0, 30, 60 ], [ 0, 30, 60 ], [ 0, 30, 60 ] ];
Games.Tala.vnz.VnzConstant.expands = [ Games.Base.Components.ExpandDirect.right, Games.Base.Components.ExpandDirect.left, Games.Base.Components.ExpandDirect.left, Games.Base.Components.ExpandDirect.right ];
Games.Tala.vnz.VnzConstant.orders = [ [ 2, 1, 0 ], [ 0, 1, 2 ], [ 0, 1, 2 ], [ 0, 1, 2 ] ];
Games.Tala.vnz.VnzResultPart.u = 'U';
Games.Tala.vnz.VnzResultPart.uKhan = 'UKhan';
Games.Tala.vnz.VnzResultPart.mom = 'Mom';
Games.Tala.vnz.VnzResultPart.uDen = 'UDen';
Games.Tala.vnz.VnzResultPart.denLang = 'DenLang';
Games.Tala.vnz.VnzResultPart.leaveGame = 'LeaveGame';
Games.Tala.vnz.VnzResultPart.empty = '';
Games.Tala.vnz.VnzResultPart._resultTexts$2 = {};
Games.Tala.vnz.VnzResultPart._resultTexts$2[Games.Tala.vnz.VnzResultPart.u] = '\u00d9!!!';
Games.Tala.vnz.VnzResultPart._resultTexts$2[Games.Tala.vnz.VnzResultPart.uKhan] = '\u00d9 khan';
Games.Tala.vnz.VnzResultPart._resultTexts$2[Games.Tala.vnz.VnzResultPart.mom] = 'M\u00f3m';
Games.Tala.vnz.VnzResultPart._resultTexts$2[Games.Tala.vnz.VnzResultPart.uDen] = '\u00d9 \u0111\u1ec1n';
Games.Tala.vnz.VnzResultPart._resultTexts$2[Games.Tala.vnz.VnzResultPart.denLang] = '\u0110\u1ec1n l\u00e0ng';
Games.Tala.vnz.VnzResultPart._resultTexts$2[Games.Tala.vnz.VnzResultPart.leaveGame] = 'B\u1ecf cu\u1ed9c';
Games.Tala.vnz.VnzResultPart._resultTexts$2[Games.Tala.vnz.VnzResultPart.empty] = '_';
Games.Tala.vnz.VnzTablePart._baseImageUrl$1 = '_Resources/TaLa/img/';
Games.Tala.vnz.VnzTablePart._cardSuiteUrl$1 = Games.Tala.vnz.VnzTablePart._baseImageUrl$1 + 'grg_allcards.png';
Games.Tala.vnz.VnzTablePart._highLightUrl$1 = Games.Tala.vnz.VnzTablePart._baseImageUrl$1 + 'v.jpg';
Games.Tala.vnz.VnzTablePart._eatImgUrl$1 = Games.Tala.vnz.VnzTablePart._baseImageUrl$1 + 'suggest_eat.png';
Games.Tala.vnz.VnzTablePart._markerImgUrl$1 = Games.Tala.vnz.VnzTablePart._baseImageUrl$1 + 'grg_card_overlay.png';
Games.Tala.vnz.VnzTablePart._cardType$1 = [ 3, 2, 1, 0 ];
Games.Tala.vnz.VnzTalaAnimation._baseImageUrl$1 = '_Resources/TaLa/img/';
Games.Tala.vnz.VnzTalaAnimation._u$1 = Games.Tala.vnz.VnzTalaAnimation._baseImageUrl$1 + 'u.png';
Games.Tala.vnz.VnzTalaAnimation._chot$1 = Games.Tala.vnz.VnzTalaAnimation._baseImageUrl$1 + 'an_cay_chot.png';
Games.Tala.vnz.VnzTalaAnimation._mom$1 = Games.Tala.vnz.VnzTalaAnimation._baseImageUrl$1 + 'mom.png';
Games.Tala.vnz.VnzTalaAnimation._uden$1 = Games.Tala.vnz.VnzTalaAnimation._baseImageUrl$1 + 'u_den.png';

// ---- Do not remove this footer ----
// This script was generated using Script# v0.5.5.0 Modified to support var & generic by VietNT B-) (http://projects.nikhilk.net/ScriptSharp)
// -----------------------------------